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

Re: bash ?



Karsten M. Self wrote:

I'd use a function.  More flexible, essentially possible to do anything
you can do in a shell script.  Though exiting is not generally
recommended:

    $ function foo () { cd /usr/share/doc; pwd; }
    $ foo
    /usr/share/doc
    $ pwd
    /usr/share/doc

The function works on the current process.  No birthing of children
involved (and less blood on your hands afterward).

Of course, there is a cost -- you're burdening your process with
remembering the function (it's stored in the processes environment).
    $ typeset -f foo
foo () { cd /usr/share/doc;
	pwd
    }


To free yourself:

   $ unset foo

Peace.




That's really cool! Thanks for the tutorial! I learned something valuable!

Kent



Reply to: