stever@tree.UUCP (Steve Rudek) (05/01/89)
I thought I'd save myself some typing by building a file of paths to all my favorite directories and then defining the following alias. alias G='cd `grep $1 /usr/local/ut/paths`' It doesn't work--for the obviously reason that $1 isn't making it to the subshell. I've tried all manner of nested quotes. Suggestions on how to do this? I'd guess it could be done with an eval...but is that really necessary?
steinbac@hpl-opus.HP.COM (Gunter Steinbach) (05/02/89)
No, aliases don't take positional arguments in kshell like they do in cshell, you have to use a "function" instead. See the ksh man page for how to make one. Here is a working version of what you wanted to do: function G { cd `grep $1 /usr/local/ut/paths`;} And don't forget the "trailing" semicolon. Good luck - Gunter Steinbach
dawn1@ihuxy.ATT.COM (Dawn E. Howe ) (05/02/89)
From article <292@tree.UUCP>, by stever@tree.UUCP (Steve Rudek): > I thought I'd save myself some typing by building a file of paths to all > my favorite directories and then defining the following alias. > alias G='cd `grep $1 /usr/local/ut/paths`' > It doesn't work--for the obviously reason that $1 isn't making it to the > subshell. I've tried all manner of nested quotes. Suggestions on how to > do this? I'd guess it could be done with an eval...but is that really > necessary? I don't have an answer for how to get your command to work, but there is something to do this ALREADY BUILT INTO KSH. Set (and export) the variable CDPATH to a colon(:)-separated list of "favorite directories". The working directory is specified by a . or a Null directory name, which can appear before the first :, after the last :, or between : delimiters. Here's how it works: -------------------- If the directory that you specify for "cd" does not begin with a /, then ksh searches each of the directories in the CDPATH in order for the specified directory, and tries to cd to that directory. Hope this helps. Dawn E. Howe AT&T Bell Labs ...dawn1@ihuxy.att.com or ...att!ihuxy!dawn1
steinbac@hpl-opus.HP.COM (Gunter Steinbach) (10/16/90)
In ksh, you need to declare a "function" if you want to pass parameters. "Alias"es don't allow them. The manual tells you how. Then "\!*" becomes simply "$*". Guenter Steinbach gunter_steinbach@hplabs.hp.com