|
Home > Archive > Unix Shell > May 2004 > TOSS_OUTPUT=' >/dev/null' doesn't work
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
TOSS_OUTPUT=' >/dev/null' doesn't work
|
|
|
|
I want to do something like this in a bash script:
if [[ $VERBOSE ]]; then
TOSS_OUTPUT=''
else
TOSS_OUTPUT=' >/dev/null'
fi
windbag $TOSS_OUTPUT
....except it doesn't work. What actually gets executed is
windbag ' >/dev/null'
Is there any way to do what I want to do? (Needless to say, windbag
does not have a --quiet option.)
Thanks!
kj
--
NOTE: In my address everything before the period is backwards.
| |
| Chris F.A. Johnson 2004-05-22, 10:28 pm |
| On 2004-05-22, kj wrote:
>
> I want to do something like this in a bash script:
>
> if [[ $VERBOSE ]]; then
> TOSS_OUTPUT=''
> else
> TOSS_OUTPUT=' >/dev/null'
> fi
>
> windbag $TOSS_OUTPUT
>
> ...except it doesn't work. What actually gets executed is
>
> windbag ' >/dev/null'
>
> Is there any way to do what I want to do? (Needless to say, windbag
> does not have a --quiet option.)
[ $VERBOSE -gt 0 ] && windbag || windbag >/dev/null
Or:
[ $VERBOSE -gt 0 ] && out=/dev/fd/1 || out=/dev/null
windbag > $out
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
| |
| Edward Lloyd Hillman 2004-05-22, 10:28 pm |
| In article <c8ocj4$e8t$1@reader2.panix.com>,
kj <socyl@987jk.com> writes:
>
>
>
>
> I want to do something like this in a bash script:
>
> if [[ $VERBOSE ]]; then
> TOSS_OUTPUT=''
> else
> TOSS_OUTPUT=' >/dev/null'
> fi
>
> windbag $TOSS_OUTPUT
>
> ...except it doesn't work. What actually gets executed is
>
> windbag ' >/dev/null'
>
> Is there any way to do what I want to do? (Needless to say, windbag
> does not have a --quiet option.)
>
> Thanks!
>
> kj
Try using double quotes (") in place of tics ('); i.e.,
if [[ $VERBOSE ]]; then
TOSS_OUTPUT=""
else
TOSS_OUTPUT=" >/dev/null"
fi
--
Ed. Hillman
Signature?!? I don't need no stinking signature!!
| |
| Barry Margolin 2004-05-22, 10:28 pm |
| In article <c8ocj4$e8t$1@reader2.panix.com>, kj <socyl@987jk.com>
wrote:
> I want to do something like this in a bash script:
>
> if [[ $VERBOSE ]]; then
> TOSS_OUTPUT=''
> else
> TOSS_OUTPUT=' >/dev/null'
> fi
>
> windbag $TOSS_OUTPUT
>
> ...except it doesn't work. What actually gets executed is
>
> windbag ' >/dev/null'
>
> Is there any way to do what I want to do? (Needless to say, windbag
> does not have a --quiet option.)
eval windbag $TOSS_OUTPUT
or:
exec 3>&1
if [[ $VERBOSE ]]
then :
else exec >/dev/null
fi
windbag
exec 1>&3 3>&-
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
| |
| Barry Margolin 2004-05-22, 10:28 pm |
| In article <10avgspe5qai47b@news.supernews.com>,
edwardh@highstream.net (Edward Lloyd Hillman) wrote:
> In article <c8ocj4$e8t$1@reader2.panix.com>,
> kj <socyl@987jk.com> writes:
>
>
> Try using double quotes (") in place of tics ('); i.e.,
> if [[ $VERBOSE ]]; then
> TOSS_OUTPUT=""
> else
> TOSS_OUTPUT=" >/dev/null"
> fi
Why? The only difference between them is whether variables and
backticks are expanded inside the quotes. Since the string contains
neither, both assignments are equivalent.
The choice of quoting at assignment time certainly has no effect on how
the string will be interpreted when it's expanded later.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
|
|
|