Re: How to get argv[0] in alias for bashrc
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Tue, 26 Sep 2006 23:11:04 -0400
On 2006-09-27, veg_all@xxxxxxxxx wrote:
any clues how i can get alias to accept the ARGV[0] which is the first
command line argument:
# .bashrc
alias transfer='wget "http://www.$ARGV[0]/temp/transfer.gz"';
When I run it I get:
--22:03:20-- http://www.%5C044argv%5B0%5D/temp/transfer.gz
=> `transfer.gz'
Resolving www.\044argv[0]... failed: Name or service not known.
In a POSIX shell, an alias is a simple substitution; the alias is
replaced with the exact string it is defined as. (Variables will
be expanded when the alias is used, if they were single-quoted,
but the positional parameters will refer to the existing
parameters, not arguments.)
In bash, "For almost every purpose, aliases are superseded by
shell functions."
transfer()
{
wget "http://www.$1/temp/transfer.gz"
}
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- References:
- How to get argv[0] in alias for bashrc
- From: veg_all
- How to get argv[0] in alias for bashrc
- Prev by Date: Re: How to get argv[0] in alias for bashrc
- Next by Date: Re: Filesystem usage by Directory wise
- Previous by thread: Re: How to get argv[0] in alias for bashrc
- Next by thread: Re: How to get argv[0] in alias for bashrc
- Index(es):
Relevant Pages
|