Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!osu-cis!att!cbnews!lvc From: lvc@cbnews.ATT.COM (Lawrence V. Cipriani) Newsgroups: comp.unix.questions Subject: Re: Overriding Parameter Expansion? Summary: use a combination of an alias with a function Message-ID: <954@cbnews.ATT.COM> Date: 25 Aug 88 13:13:31 GMT References: <810026@hpsemc.HP.COM> Organization: AT&T Bell Laboratories, Columbus Lines: 46 In article <810026@hpsemc.HP.COM>, gph@hpsemc.HP.COM (Paul Houtz ) writes: > Does any one know if it is possible for a program or function to > tell whether the shell (especially csh or ksh) has expanded a > parameter into multiple file names? A UNIX(tm) program cannot determine how it's argument list was generated. I don't know about csh. For ksh you can use a combination on an alias and a function to control filename generation. For example: alias myfunc='set -f;_myfunc' function _myfunc { trap 'set +f' EXIT # not sure of the exact syntax here ...whatever... } > It would be nice if I could at least know that expansion has > occurred in parameter 1. You'll have to be careful to check if * expands to * when there are no matching filenames. > Note, I do NOT want to turn off parameter expansion (set -f) > in my shell. I also do NOT want to quote the parameters, e.g., > I do not want to say myfunc "*" file2 file3. This turns it off during the function execution and then turns it back on when the function completes. Good enough? > Since there are commands that will do the filename expansion for you, > doesn't it seem contrary to the basic idea of UNIX that this expansion > is done for you automatically by the shell? I like it being in the shell primarily for consistency and secondarily for efficiency. > Normally unix [sic] does not > get in my way, but in this example it does. I wouldn't mind if I had > to expand my parameters myself. I think I should be able to invoke > a function and have access to the raw parameters with a shell script. > (and more than 9, too.) Oh well. With ksh you can access up to 99 arguments, and can get access to the 'raw' parameters as I have shown. -- Larry Cipriani, AT&T Network Systems, Columbus OH, cbnews!lvc lvc@cbnews.ATT.COM