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 
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

What you're doing is tryting to run grep on /dev/hda7. Let's hope you 
don't have read access!

> 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
}

(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.

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.


> "All scripture is God-breathed and is useful for teaching,
> rebuking, correcting, and training in righteoousness."
>                                       2 Timothy 3:16 NIV

And still I help you.


Randall Schulz
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to