bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditional aliases are broken


From: Sam Steingold
Subject: Re: conditional aliases are broken
Date: Thu, 18 Aug 2011 10:38:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> * Eric Blake <address@hidden> [2011-08-15 16:59:29 -0600]:
>
> On 08/15/2011 04:40 PM, Sam Steingold wrote:
>>> * Andreas Schwab<address@hidden>  [2011-08-15 22:04:04 +0200]:
>>>
>>> Sam Steingold<address@hidden>  writes:
>>>
>>>> Cool.  Now, what does this imply?
>>>
>>>     "For almost every purpose, shell functions are preferred over aliases."
>>
>> so, how do I write
>>
>> alias a=b
>>
>> as a function?
>> (remember that arguments may contain spaces&c)
>
> a() { b "$@"; }

mkdir z
cd z
touch a b 'c d'

how do I write a function that would print the same as
$ \ls | cat
a
b
c d
$


$ f1(){ for a in "$*"; do echo $a; done; }
$ f1 *
a b c d
$

$ f2(){ for a in $*; do echo $a; done; }
$ f2 *
a
b
c
d
$


-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 
11.0.60900031
http://ffii.org http://honestreporting.com http://www.memritv.org
http://thereligionofpeace.com http://mideasttruth.com http://dhimmi.com
UNIX is a way of thinking.  Windows is a way of not thinking.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]