referring to arguments in bash aliases

Harry Putnam reader at newsguy.com
Thu Mar 4 08:28:18 UTC 2004


Timothy Stone <citylists at petmystone.com> writes:

> I've got this far:
>
> llm() { }
>
> It's a start right? ;) Am I headed down the right path? Did I read to
> much between the lines in the man pages for bash? Nothing on the web
> dives this far into aliases in bash. Much seems to skip arguments in
> the alias' replacement text.

I think functions side step some problems aliases have.  I seem to
remember aliases not living thru some situations where functions are
still available.  But didn't try to reproduce.

You may have hit a problem I hit long ago when I started using bash
functions. 

syntax should be:

  name () { some.cmd; }

All ingredients are important... The space after and before {}
The semi-colon after `some.cmd'

They can be fairly elaborate if you watch the syntax.  Here is my most
elaborate one in current use:

enlp () { if [ -z "$1" -o "$1" = help ];then
              echo "Usage: \`enlp [args]  FNAME'"
              echo "Current args are:"
              echo "   enscript -f AvantGarde-Book10/12 -F Times-Roman at 14/16 \\"
              echo "    --margins=60::: --word-wrap -G "
          else
enscript -f AvantGarde-Book10/12 -F Times-Roman at 14/16 --margins=60::: --word-wra
p -G "$@"
       enscript -f AvantGarde-Book10/12 -F Times-Roman at 14/16 --word-wrap $1
          fi; }

Functions can be sourced same as other env stuff.

   . .functions.file





More information about the redhat-list mailing list