[squeak-dev] script arguments with spaces
Eliot Miranda
eliot.miranda at gmail.com
Fri Oct 8 22:36:37 UTC 2010
Hi Chris,
On Fri, Oct 8, 2010 at 9:44 AM, Chris Muller <asqueaker at gmail.com> wrote:
> > Of course. Try it and see. This is a shell issue. What's the syntax to
> > supply an arg containing spaces. On Unix there are
> > two^H^H^Hthree^H^H^H^H^Hfour ways. Escape spaces with back slashes, use
> IFS
> > to make space a non-separator and separate words using e.g. TAB (I think
> > this works), surround the argument with single quotes or surround the arg
> > with double quotes.
>
> Right I did try all of those things of course (except adjusting IFS),
> but it appears that Squeak puts its own interpretation onto these
> arguments differently from the shell. IOW, Squeak appears to be doing
> a simple subStrings operation regardless of escape-characters when
> loading up the systemAttribute array... For example:
>
> st '1000 factorial' <----- Squeak gets 2 args, '1000' and 'factorial'
> st "1000\ factorial" <----- Squeak gets 2 args, '1000\' and 'factorial'
>
> Strings are a challenge because the shell does not allow single-ticks
> inside of single-ticks, but one can use Symbols:
>
> st '#hello asString asUppercase' <--------- Squeak gets 3 args...
>
> My goal is to deliver a "Smalltalk command-line". I did find that
> your stdin works, so I can do:
>
> st <<printit
> 'hello' asUppercase
> printit
>
> works. :)
>
Bert is very probably right. If you're suing bourne/bash then look up
the difference between $*, "$*", $@ and "$@". To preserve spaces you need
to use $@/"$@" (depending on context" *not* $*. Also within your script you
can use IFS to prevent space being a separator.
HTH
Eliot
>
> >>
> >> I actually want to allow the Linux user to specify a chunk of code
> >> (which contains spaces) on the command-line.
> >>
> >> I tried enclosing it in ticks, but Squeak still loaded each
> >> system-attribute into its own slot. Interestingly, it did not include
> >> the beginning or ending tick.
> >>
> >> So, it looks like I could assemble all of the pieces, separatedBy:
> >> Character space, but that would limit the chunk to 997 "words"..
> >>
> >
> >
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20101008/546a911c/attachment.htm
More information about the Squeak-dev
mailing list
|