Mailinglist Archive: opensuse (2496 mails)

< Previous Next >
Re: [opensuse] .bashrc alias - One Liner Problem?
  • From: Anders Johansson <ajohansson@xxxxxxx>
  • Date: Mon, 1 Dec 2008 19:17:33 +0100
  • Message-id: <200812011917.33630.ajohansson@xxxxxxx>
On Monday 01 December 2008 19:12:24 David C. Rankin wrote:
I finally resolved to the function idea Aaron first suggested.

Who is Aaron?


wpsearch ()
{
if [[ $1 ]]; then
webpin $1
else
echo -e "\n\tusage: wp <filename>\n"
fi
}

alias wp='wpsearch $1'

This is pointless. "wp konqueror" expands to

wpsearch $1 konqueror

and the only reason your alias works is that this is a valid string, since $1
is the empty string after expansion. But try starting this from a script where
you pass parameters. Then $1 won't be empty, and then you will get weird
results


I guess I've been lucky using $1 with aliases. I don't know how they
work,
but they work in most instances for me:

alias hist='history | grep $1' #Requires one input
alias tmsg='sudo tail $1 -n50 /var/log/messages' # -f to follow
alias tmi='sudo tail $1 -n50 /var/log/mail.info' # -f to follow
alias umnt='/home/david/bin/alias_umnt $1'
alias wg='[[ -n $1 ]] || echo -e "\n\tUsage: wg <filename>\t\t(runs wget
--no-check-certificate --progress=bar)\n"; wget --no-check-certificate
--progress=bar $1' #requires input
alias zu='/home/david/linux/scripts/config/zypp/zypp_auto $1' # either up
for patches or -t packages for pagkages
alias znr='sudo zypper nr $1 $2' # requires two inputs <old repo alias>
<new repo alias>

Same thing for all of these. "hist konqueror" expands to

history | grep $1 konqueror

which works because $1 is the empty string. tmsg -f expands to

sudo tail $1 -n 50 /var/log/messages -f

which again is a valid command line

And so on and so on and so forth

Anders
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
References