spaces in pathnames
Roland Mainz
roland.mainz at nrubsig.org
Sun Jun 29 19:55:27 PDT 2008
Jeremy Huddleston wrote:
> On Jun 29, 2008, at 19:18, Roland Mainz wrote:
> > Jeremy Huddleston wrote:
> >>
> >> So I just pushed a patch to xinit that addresses some issues with
> >> spaces in pathnames. One issue remains, and I'm not sure if
> >> there's a
> >> clean way to address it. At first, I thought I could do something
> >> like this:
> >>
> >> - serverargs=${serverargs}" -auth "${xserverauthfile}
> >> + serverargs=${serverargs}" -auth '"${xserverauthfile}"'"
>
> > AFAIK on any POSIX-like shell a simple...
> > -- snip --
> > IFS=''
> > -- snip --
> > ... should fix the problem.
>
> Yeah, but then we don't get separation when we do want it:
>
> ~/src $ mya="some thing with spaces"
> ~/src $ myb="other spaces"
> ~/src $ myargs="-auth "$mya
> ~/src $ ./printargs "$myb" $myargs
> argv[0] = ./printargs
> argv[1] = other spaces
> argv[2] = -auth some thing with spaces
[snip]
What about using "shift" and then "$@" ([1], assuming the extra args
come at the end of the command line, otherwise you have to do the
"trick" with the "set" builtin below) ?
Example:
-- snip --
more_args="foo bar"
IFS=' ' set -- ${more_args}
printf "|%s|\n" 1 2 3 "$@"
-- snip --
(note that "printf" will repeat the format string until it's argv is
completely used-up - in this case the format string only "eats" one
argument and therefore it's repeated for each of the arguments).
The output should look like this:
-- snip --
$ ksh93 xxx.sh
|1|
|2|
|3|
|foo|
|bar|
-- snip --
[1]="$@" expands each element in the argument array to it's value
surrounded by double-quotes.
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL <currently fluctuating>
(;O/ \/ \O;)
More information about the xorg
mailing list