system command
Fairlight
fairlite at fairlite.com
Mon Oct 31 18:54:07 PST 2005
On Mon, Oct 31, 2005 at 09:14:43PM -0500, after drawing runes in goat's blood,
Kenneth Brody cast forth these immortal, mystical words:
> Quoting Fairlight (Mon, 31 Oct 2005 20:48:00 -0500):
>
> [...]
> > > Remember, in order to do something like:
> > >
> > > echo '\033'
> > >
> > > you need to escape the backslash to get the shell to see it:
> > >
> > > sh -c "echo '\\033'"
> > >
> > > (Note: I have not actually verified the above, as I'm not on a *nix
> > > box at the moment.)
> >
> > Not from what I'm seeing. The point in fact is that his single
> > backslash in "\033" shows up in `less` as an actual binary ESC code.
> > So...no, it doesn't -seem- that you need to escape it an extra level.
> [...]
>
> Let's make this "simpler". Try echoing a backslash.
>
> >From the command prompt:
>
> echo \\
>
> But, in order to call the shell to echo a backslash you need:
>
> sh -c "echo \\\\"
>
> ==========
> $ echo \\
> \
> $ sh -c "echo \\"
> sh: -c: line 2: syntax error: unexpected end of file
> $ sh -c "echo \\\\"
> \
> $
> ==========
[cobalt] [~] [9:44pm]: sh -c "echo \\\\"
\\
[cobalt] [~] [9:44pm]: sh -c "echo "\\\\""
\
[cobalt] [~] [9:44pm]:
There's one difference. In his example, the ENTIRE argument to echo, the
whole string, is within doublequotes.
But in filePro, let's look at what should be happening as opposed to what
is:
\\\" is given inside part of a literal string within "". To me, this
translates as "literal backslash, literal doublequote". What the shell
does with this is one thing, and I can see how he might end up with a
single backslash after interpolation by sh.
However, what -worked- was \\\\" inside ""s. This reads to me as the
above, but with a spurious backslash that should actually not be properly
interpolatable -before- it ever hits the shell by system call. If you take
it left to right, you have a literal backslash with the first two, another
literal backslash with the second two, and a single-quote that -should- end
the literal string, causing an unbalanced-quote parsing error in fP.
THIS is why I'm confused. It shouldn't work at the -fP- level, nevermind
the shell. Take this: "\\\\""
You start a literal string, escape for a literal \, escape for another
literal \, end the literal string by accident, and have a spurious
character at the end with the third ".
Why does this even pass syntax check, much less -work-?
mark->
More information about the Filepro-list
mailing list