Re: coupl'a silly questions (and another)


Subject: Re: coupl'a silly questions (and another)
From: Patrick Smith (patsmith@pobox.com)
Date: Sat Aug 25 2001 - 22:24:37 MDT


> OK, being totally new to functions in bash:
>
> Are functions declared starting with the term, "function?" i.e.:
> function new() { ls -lt ${@+"$@"} | head; }

Yes, although the word "function" is optional.

> Would the function statement go in my .bashrc file, for example,
> sourced on login?

If you want to always have the function available at the command line,
you should put it in both .bashrc and .bash_login. (Or do as I do, and
make .bash_login a symbolic link to .bashrc.)

> What would cause the following syntax error?
> % function new() { ls -lt ${@+"$@"} | head; }
> % new /etc/
> bash: syntax error near unexpected token `/etc'

I'm not sure. It works for me:

% function new() { ls -lt ${@+"$@"} | head; }
% new /etc/
total 2068
-rw-r--r-- 1 root root 67 Aug 25 11:35 issue
-rw-r--r-- 1 root root 0 Aug 25 11:35 issue.net
-rw------- 1 root root 60 Aug 25 11:35 ioctl.save
-rw-r--r-- 1 root root 152 Aug 25 11:35 mtab
-rw-r--r-- 1 root root 334 Aug 14 16:38 crontab
drwxr-xr-x 2 root root 4096 Aug 14 16:37 cron.daily
drwxr-xr-x 2 root root 4096 Aug 14 16:37 cron.hourly
drwxrwxr-x 2 news news 4096 Aug 14 16:37 news
-rw-r--r-- 1 root root 552 Aug 11 21:55 yaboot.conf

Maybe you still have your old alias for new in effect? If so, that
would override the function.

-- 
patsmith@pobox.com



This archive was generated by hypermail 2a24 : Sat Aug 25 2001 - 21:33:20 MDT