On 2007/07/28 13:58 (GMT-0700) Randall R Schulz apparently typed:
> On Saturday 28 July 2007 13:32, Felix Miata wrote:
>> I'm having no luck figuring out why
>> alias Vol='tune2fs -l $1 | grep volume'
> Aliases don't take positional parameters, at least not in BASH (I think
So it's just an accident that the following aliases all work as I want/expect?
alias ll='ls -l $*'
alias rpmqa='rpm -qa | grep $*'
alias test='echo $*'
alias vol='tune2fs -l $1'
> they do in the Csh family, if I recall correctly). They simply expanded
> verbatim in front of any arguments you give, so if you invoke it
> with "/dev/hda7" as an argument, it's like running this command:
> % tune2fs -l $1 | grep volume /dev/hda7
It's still clear as mud how "don't take positional parameters" translates
into moving /dev/hda7 to the end of the whole string.
> What you're doing is tryting to run grep on /dev/hda7. Let's hope you
> don't have read access!
I see what you wrote, but don't understand how /dev/hda7 shows up at the end
of everything.
>> causes a usage message when 'Vol /dev/hda7' is run. Can anyone
>> explain what I'm doing wrong, or provide a better method to discover
>> a volume label? --
> Unlike the very limited capabilities of aliases, shell procedures are
> just like separate scripts, except no file need be loaded to invoke
> them. You can get the effect I think you want with this:
> Vol() {
> tune2fs -l "$1" |grep volume
> }
I made a script with nothing but that in it, but it returns nothing.
> (If you put that all on one line, you'll need a semicolon after "volume"
> and before the closing brace.)
> Beware that if you're going to try this, you should undefine the alias
> first. They intefere, and if I'm not mistaken the alias will override
> the shell procedure.
> Once you get something you like, put it in your .bashrc, though
> realistically, there's no particular reason not to just make a shell
> script out of this.
Other than the quotes, I don't see the difference between the content of your
sample script, and putting essentially the same thing into .bashrc, which is
where all my aliases live, and why I use aliases instead of simple scripts
(easier to copy one file to new username on new installation).
> Lastly, don't use an "exit" for early return in a shell procedure. It
> will apply to the shell that invoked it. There's a "return" keyword
> that works the same as exit and causes just the shell procedure to
> terminate before reaching its last statement, not the whole shell.
I appreciate the reply, but I'm not sure I understand any more now than I did
before starting the thread. :-(
--
"All scripture is God-breathed and is useful for teaching,
rebuking, correcting, and training in righteoousness."
2 Timothy 3:16 NIV
Team OS/2 ** Reg. Linux User #211409
Felix Miata *** http://mrmazda.no-ip.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]