Mailinglist Archive: opensuse (1986 mails)

< Previous Next >
[opensuse] .bashrc alias - One Liner Problem?
  • From: "David C. Rankin" <drankinatty@xxxxxxxxxxxxxxxxxx>
  • Date: Sun, 30 Nov 2008 14:07:51 -0600
  • Message-id: <4932F297.2090200@xxxxxxxxxxxxxxxxxx>
Listmates,

Usually I can make my 1-liner aliases work the way I want. However, I'm
stumped by a simple webpin alias and its refusal to do what I think I'm telling
it to do. Generally, I just use:

alias wp='webpin $1'

But I wanted to have it give usage information if no argument was given
instead of just the default webpin "ERROR: you must specify the search criteria
as a parameter" if no search term was specified.

The simple logic I wanted was and that works fine in a separate script
is:

if [[ $1 ]]; then
webpin $1
else
echo -e "\n\tusage: wp <filename>\n"
exit 1
fi

However, when I try and turn it into a 1-liner I get the expected
results for
the echo statement, but I get the following error when webpin $1 is called:

alias wp='if [[ $1 ]]; then webpin $1; else echo -e "\n\tusage: wp
<filename>\n"; fi'

13:45 nirvana~/linux/scripts/test> wp

usage: wp <filename>

13:49 nirvana~/linux/scripts/test> wp konqueror
-bash: syntax error near unexpected token `konqueror'

I look on both sides of the $1 in "webpin $1;" and I can't see any
thing wrong.

To get around this, I have tried various connotations of || and &&
logic, but
I can't get either an exclusive execution of webpin or the usage statement,
such as:

alias wp='[[ $1 ]] && webpin $1 || echo -e "\n\tusage: wp <filename>\n"'

Which works from the command line, but not as an alias.

So my question is "what basic bash rule am I screwing up this time,
and, how
do I fix it?" Thanks.

--
David C. Rankin, J.D.,P.E. | openSoftware und SystemEntwicklung
Rankin Law Firm, PLLC | Countdown for openSuSE 11.1
www.rankinlawfirm.com | http://counter.opensuse.org/11.1/small
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >