Git Product home page Git Product logo

Comments (20)

warjiang avatar warjiang commented on August 25, 2024

@lonnywong plz help

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

@warjiang Does openssh work properly?

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

@warjiang Does openssh work properly?

Yeah, it works

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

openssh supports # without ' and ":

Host test
    LocalCommand echo Hello# World
    PermitLocalCommand yes

Need to study how openssh does it. But I've been busy recently.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

@lonnywong

First i should admit that i have little knowledge of openssh, even bunch of knowledge came from daily usage 🤣 .

May be it's not right time to talk further, you can recheck this when you are free. Feel free to review it 😄 .
What i want to express is that, the ssh_config pkg cannot parse # char in side string literal.

The test code as follow:

func main() {
	configData := `Host test
    LocalCommand echo Hello'#' World
    PermitLocalCommand yes`
	cfg, err := ssh_config.Decode(strings.NewReader(configData))
	if err != nil {
		panic(err)
	}
	v, err := cfg.Get("test", "LocalCommand")
	if err != nil {
		panic(err)
	}
	debug("value is %s", v)
}

before fixed:
image

after fixed:
image

Apart from that, i've tested in openssh client, i mock a ssh config file like following:

Host wap1
    LocalCommand echo Hello'#' World
    PermitLocalCommand yes

image

it's equla to command echo Hello'#' World no echo Hello'

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

what i do is that handel the # within string literal, it's not enough, but it can work currentlly. After a brief view of openssh: https://github.com/openssh/openssh-portable/blob/master/readconf.c,
image
openssh lib also handle the ssh config with ast like tokenizer, lexer and so on. But the token is much more than ssh_config 😭
May we can talk it further in the futhre when free.

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

@warjiang How about we make some changes like this:

Host comment
    Key1 = Value1 # This is part of the value, not a comment
    Key2   Value2 # This is a comment, not part of the value

The value of Key1 is Value1 # This is part of the value, not a comment. And the value of Key2 is Value2.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

@warjiang How about we make some changes like this:

Host comment
    Key1 = Value1 # This is part of the value, not a comment
    Key2   Value2 # This is a comment, not part of the value

The value of Key1 is Value1 # This is part of the value, not a comment. And the value of Key2 is Value2.

we should distinguish scene of #

  • # in side single quote or doule quote
    in this case, # should be treated as a common literal
  • # not in side single quote or doule quote
    in this case, # should be treated as grammar of comment

so @lonnywong should change code as following, if you want # as part of value

Host comment
    Key1 = 'Value1 # This is part of the value, not a comment'
    Key2   Value2 # This is a comment, not part of the value

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

It's not clear whether the value 'Value1 # This is part of the value, not a comment' contains single quotes or not.

I think = means there is no comment at the end, which is simple and easy to distinguish. It's not exactly the same as openssh, but it's worth it.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

i've made serval test cases it in my local enviroment

Host wap
    LocalCommand = echo Value1 # This is part of the value, not a comment
    PermitLocalCommand yes

image

Host wap
    LocalCommand echo Value1 # This is part of the value, not a comment
    PermitLocalCommand yes

image

Conculsion: whether use equal sign, it turns out the same effect.

if wrap # with single quote as follow:

Host wap
    LocalCommand echo 'Value1 # This is part of the value, not a comment'
    PermitLocalCommand yes

image

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

I mean we change the code to do that.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

It's not clear whether the value 'Value1 # This is part of the value, not a comment' contains single quotes or not.

I think = means there is no comment at the end, which is simple and easy to distinguish. It's not exactly the same as openssh, but it's worth it.

maybe you are right, but it will casued some extra knowledge of another version of ssh config (like config of tssh) 😆 .

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

I mean we change the code to do that.

i can try it, but maybe we can use option to let user to choose whehter enable this feature.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

how about another im tools like wechat or tg? may be we can talk it for further. the work under trzsz is very useful for me, maybe i can take part in these project in deep. 🤔

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

i can try it, but maybe we can use option to let user to choose whehter enable this feature.

I think most people will not use = in ssh config, even fewer use = and add comments at the end of the line.

We just need to document the new features of = in the new version.

how about another im tools like wechat or tg? may be we can talk it for further. the work under trzsz is very useful for me, maybe i can take part in these project in deep. 🤔

There's a QQ group at the bottom of README.

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

I think most people will not use = in ssh config, even fewer use = and add comments at the end of the line.

We just need to document the new features of = in the new version.

that's true~ i'll try it later 🔧

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

I've implemented this feature by add lexRReservedvalue state. After detect equal, it will go to state of checking lexRReservedvalue.
image

from trzsz-ssh.

warjiang avatar warjiang commented on August 25, 2024

I've implemented this feature by add lexRReservedvalue state. After detect equal, it will go to state of checking lexRReservedvalue. image

for the ssh config as following:

Host comment
    Key1 = Value1 # This is part of the value, not a comment
    Key2   Value2 # This is a comment, not part of the value

the test case like following:
image

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

I will write the documentation and update it this weekend.

from trzsz-ssh.

lonnywong avatar lonnywong commented on August 25, 2024

done a6c64a6

from trzsz-ssh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.