Overriding Parameter Expansion?

Paul Houtz gph at hpsemc.HP.COM
Wed Aug 24 01:05:54 AEST 1988


  
   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?

   I know that the it is designed to do this, but I need to eliminate the
   possibility.

   For example:

     myfunc () {
       echo $1
       echo $2
       echo $3
       }

    If I type in myfunc file1 file2 file3, then the results are
      file1
      file2
      file3

    If I type in myfunc * file2 file3
  
      then the results are
       first_file_in_directory
       second_file_in_directory
       third_file_in_directory 

   It would be nice if I could at least know that expansion has 
   occurred in parameter 1.    

   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.

   Finally, something to consider:

   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?   Normally unix 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. 
 



More information about the Comp.unix.questions mailing list