Re: FAQ 8.28 How can I call backticks without shell processing?



"s" == szr <szrRE@xxxxxxxxxxxxxxx> writes:

s> Uri Guttman wrote:
>>>>>>> "s" == szr <szrRE@xxxxxxxxxxxxxxx> writes:

>> perl -e '@e = qw( a b c ); open( $e, "-|", 'echo', @e ); print <$e>'
>> a b c
>>
>> echo printed its args with spaces as expected so it got 3 separate
>> args and not 'abc' as you claim it would.

s> Curious, I thought the behavior would be like:
s> $ perl -e '@e = qw( a b c ); print @e'
s> which yields 'abc', as I saw that after the first three arguement of the
s> normal 3 arg open() it appeared to take a list of additional args that
s> is passes to what ever you opened. I didn't know it separates them like
s> it does. Good to know.

you don't get what is happening there. perl is printing each element and
there is no separator so it appears you are concatenating. when you exec
with a list each argument is separated in the same way and it depends on
the exec'ed program how they will be used. echo puts spaces between them
which is why i chose that for the one liner. i could have used perl
again and it would not have put spaces in unless i made it do so (as
with "@e").

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.



Relevant Pages

  • Re: FAQ 8.28 How can I call backticks without shell processing?
    ... this invokes exec with a list (see ... echo printed its args with spaces as expected so it got 3 separate ... args and not 'abc' as you claim it would. ...
    (comp.lang.perl.misc)
  • Re: Hiding symbols in shared library
    ... Henrik Goldman wrote: ... Generally you should not separate ld options and their args with separate ... (Of course you can go crazy by combining them into all one -Wl. ...
    (comp.sys.hp.hpux)
  • Re: parameter expansion
    ... On Sat, 07 Feb 2004 at 14:24 GMT, A Alper ATICI wrote: ... is a separate word, and $IFS is not used. ...
    (comp.unix.shell)
  • Re: tr
    ... >> You may need to put single ticks around the tr args, depending on ... >> clashes once you convert to upper case, e.g. abc and aBC both become ... it depends in which shell you're using. ...
    (comp.unix.shell)
  • Re: tr
    ... > You may need to put single ticks around the tr args, depending on ... > clashes once you convert to upper case, e.g. abc and aBC both become ... it depends in which shell you're using. ...
    (comp.unix.shell)