Hello, On Sun, 30 Nov 2008, David C. Rankin wrote:
alias wp='webpin $1'
That does not work as you think. Aliases are substituted, not called with arguments. ==== man bash ==== ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. ====
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.
You can't.
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
A script get's passed arguments.
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'
Note what happens if I add a ';' at the end: $ alias foo='if [[ $1 ]]; then webpin $1; else echo -e "\tusage: p <filename>"; fi;' $ foo a b c $ foo a b c + [[ -n '' ]] + echo -e '\tusage: wp <filename>' usage: wp <filename> + a b c bash: a: command not found Which is because foo a b c is substituted to: if [[ $1 ]]; then ... fi; a b c (and "$1" expands to nothing).
So my question is "what basic bash rule am I screwing up this time, and, how do I fix it?" Thanks.
See above. Use a function: wp() { if test -n "$1"; then webpin "$@"; else echo -e "..."; fi; } Passing "$@" instead of just "$1" to webpin makes it more flexible as you can pass options to wepin, e.g. "wp -d latest konqueror" HTH, -dnh --
This needs quotes: use lib "/path/to/perl/modules"; Single or double quotes? Yes. -- Tad McClellan in comp.lang.perl.misc -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org