[squeak-dev] wildcard expansion with OSProcess outputOf: through ssh

David T. Lewis lewis at mail.msen.com
Sun Jul 10 17:00:53 UTC 2022


Hi Chris,

I will be away for a couple of weeks so I can't follow up now, but
a couple of thoughts below.

On Wed, Jul 06, 2022 at 08:57:35PM -0500, Chris Muller wrote:
> 
> > The next issue is that we are trying to invoke one of these command lines
> > using CommandShell, which is yet another layer of shell command line
> > interpretation.
> > CommandShell is a very simple unix-like shell, but it does
> > not include things that you would expect from a bash shell such as shell
> > variables and proper escaping of wild cards. I do not have a suggestion
> > to addess this at the moment but I'll try to follow up with something later.
> 
> Oh, that's good to know.  I just tried,
> 
>    OSProcess outputOf: 'echo $HOME'
> 
> and it returned '$HOME'.  Yikes!
> 
> Hmm.. this is an unexpected limitation.
> ..
> I just tried to quickly research a way to pass a string of key=value's
> syntax to the bash command itself, something like:
> 
>    OSProcess outputOf: 'bash --environment ''key1=value1'' -c ''ssh
> dan ''cat /sys/class/net/*/address'''
> 
> where my code would replace "key1=value1", above, with every entry in
> the 'environment' Dictionary of UnixProcess, which appears to contain
> the environment for the squeak vm process.
> 

The simulation of shell sytax lives mainly in class ShellSyntax, see
ShellSyntaxTestCase to see how it works. This was meant to be a crude
but effective simulation, but it's probably more the former than the latter.

Single quote escaping is supported, but double-quote escaping is not,
so there's really no way to pass single quote expansion within a
string escaped by double (or single) quotes. It's kind of a question
of where you stop on a project like this, I really was not intending
to reimplement a full Bourne shell, so I just hand-coded a few pieces
of simple shell-like syntax and let it go at that.

> --environment, above, is bogus, just for illustration, I don't know
> quite how to do it.  I don't even know if this is a good approach at
> all.
>

As a practical matter you may be best off to put the fancy stuff into
a real shell script file and just run that from OSProcess.

Dave



More information about the Squeak-dev mailing list