On Tuesday 19 October 2004 23:45, Yedidyah Bar-David wrote:
> I do not want to make this look as some stupid contest, and intended not
> to reply, hoping for the thread to die.

My fault. I transformed it into a "contest" because it started
with a naive question by a newbie about shell redirection/piping
and I prefered some "interesting" shell structures.

Indeed we quickly demonstrated two different approaches which
are not trivial for newbies.

> % xargs -0 cat < t
> cat: me "Shlomo" "hello there,
> how are you"
> : No such file or directory
> Now it's all one arg. Or, if you prefer, a variation:
> % cat t | tr '\012' '\000' | xargs -0 cat
> cat: me "Shlomo" "hello there,: No such file or directory
> cat: how are you": No such file or directory
> Still not what you showed, but you did not exactly define what you want.

The original poster wanted sendsms to receive 3 args taken from
the file when the last argument is the message which may contain
multiple words. Than someone else extended the problem -- what if
the message is spread accross lines.

While the extended problem was handled ok with my eval (but see below),
it was not ok with xargs and your latest two examples are very good
because they demonstrate the difference: xargs does not interpret
the quotes I put in the file -- therefore it is sensitive to the
line breaks (or the nulls that you put instead of them in the second
example).

> > >  $ eval cat "`cat /tmp/t`"
> > >  cat: me: No such file or directory
> > >  cat: Shlomo: No such file or directory
> > >  cat: hello there, how are you: No such file or directory
> 
> This isn't what happens in my shell:
> % eval cat "`cat t`"

I AM RETARDED (and also stealing quotes from Linus BTW :-).
My interactive shell is tcsh (as you noted below).

> That's bash 3 in Debian sid. The manpage does mention there is an option
> to make it behave like what you show, but I do not have time to test
> this.

Ok, I have homework. The extended problem is still unsolved in bash
(pass 3 arguments from a file to command line while the 3'rd argument
may be quoted sentence across lines).

> And, BTW - the reason you got what you wanted is because of the 'eval',
> not the backquotes. Without it, they will still count as one long word,
> or many short ones, depending on whether you put the extra '"' you did
> or not.

Sure, the whole point was to show some power of eval -- just chose
the wrong shell for it...

> > >Seems like I just won the bash-judo :-)

1. s/bash/tcsh/    (boooo).
2. This judo is not about Oron against Didi it's about us against
   the shell.

> I just want to make something clear - unix has
> ...

I trimmed a good and correct description of the hazard of
using powerfull tools without care, and specifically
about the relative robustness of xargs vs. shell backticks.
I agree with both points (and unintentionally provided
a good example for avoiding complex shell structures
when possible).

Still... the challenge remains (anybody?)

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]                  http://www.actcom.co.il/~oron
ICQ UIN: 16527398

Some people claim that the UNIX learning curve is steep, but at least
you only have to climb it once

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to