[Ilugc] One Day One Command

  • From: trshash84@xxxxxxxxx (T.R.Shashwath)
  • Date: Fri Jan 7 01:07:04 2005

Try writing a whole script within an alias... Somewhat useless, but could be 
useful also.

On Thursday 06 Jan 2005 7:09 pm, Suraj wrote:

T.R.Shashwath wrote:
,----

| ...Including the ability to use a whole function definition in it...
|
| alias something="foo() { echo $bar }

`----

you can 'define'  a function, yes.  But whats your  point?  alias is a
literal expansion.  its very much like a pre-processor operation.

alias foo="function bar() { echo hello world; }"

will only  'define' the function 'bar'  when you type  'foo'. Its just
that instead of  having to type of the entire  function, you typed out
'foo'. and the above example is slightly misleading, in a way, in that
if people try to type 'foo test message', they would get syntax errors
because it does literal expansion.

some examples:

$ alias intemp="cd /tmp; "
$ intemp ls
<output of ls>
$ pwd
/tmp

$ alias obfuscated="function myfunc() {"
$ obfuscated echo hello world; }; myfunc
hello world
$

cheers,

  -Suraj

-- 
To know a thing well, know its limits. 
Only when pushed beyond its tolerances will true nature be seen.
--The Amtal Rule - Dune

Other related posts: