bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to protect > and interpret it later on? (w/o using eval)


From: Greg Wooledge
Subject: Re: How to protect > and interpret it later on? (w/o using eval)
Date: Fri, 2 Dec 2011 08:28:35 -0500
User-agent: Mutt/1.4.2.3i

On Fri, Dec 02, 2011 at 09:00:10AM +0200, Pierre Gaston wrote:
> On Fri, Dec 2, 2011 at 8:24 AM, Peng Yu <pengyu.ut@gmail.com> wrote:
> > $  ../execute.sh  ls >/tmp/tmp.txt

What?  You have a pipeline with nothing before it, and then another
pipeline with "ls" on the right hand side.  But ls doesn't even read
from stdin!

This is not even syntactically valid:

arc3:/tmp$ | echo | ls
bash: syntax error near unexpected token `|'

And it's not semantically valid either, because piping to ls is ludicrous:

arc3:/tmp$ echo hello world | ls
arc3:/tmp$ 

> > '>' will not work unless eval is used in execute.sh.

WHAT are you trying to DO?

> > $ ../execute.sh  ls '>' /tmp/tmp.txt

... another pipe to ls!  What on earth is this?

> > How to make execute protect > and interpret it later on w/o using eval?

Your execute.sh script never even sees the > at all, because you are
not passing the > as an *argument* to the ../execute.sh script.  You
are passing it as an argument to ls.  ../execute.sh has *no* arguments
whatsoever.

> This really belongs to the new help-bash@gnu.org mailing list
> * https://lists.gnu.org/mailman/listinfo/help-bash

Agreed.

Here, this is my best guess as to what he wants:

  http://mywiki.wooledge.org/BashFAQ/050 -- I'm trying to put a
  command in a variable, but the complex cases always fail!

If that doesn't cover it, then post (on help-bash) an English description
of the actual *goal* you are trying to achieve.

If you feel you must post code, then at least make sure the code is
DIRECTLY COPIED FROM YOUR TERMINAL, not made up on the spot with syntax
errors in it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]