Paul Jarc wrote: > Bob Proulx wrote: > > Also, using full paths is frowned upon. > > You mean invoking /directory/some-command directly instead of > PATH=$PATH:/directory > some-command > ?
Yes. That is what I am saying. > It depends on the situation. I can't disagree with that. > If you think some-command is in /directory, but you want to allow > for the possibility that it might be somewhere else in $PATH, then > augmenting $PATH and invoking some-command by its basename is > better. On the other hand, if you know that the some-command you > want is definitely in /directory, and if there could be other > versions of some-command elsewhere in $PATH that are different from > the one you want, then it's best to invoke /directory/some-command > by its full path. I think what you said is that everything depends upon exactly what you want to do. And you are good enough that you would know what you wanted to do and my general guidelines won't always apply. But you were not the one asking the question and not within my response target set. I was actually commenting on a previous suggestion earlier in the thread that full paths be used. I was compelled to object to that suggestion. I have seen too many scripts that people write with full paths *thinking* that they are making the script stronger when in reality they are making it more fragile. More fragile because they are then fixing the script into the rigid framework of a particular system. That is the case I am frowning upon. #!/bin/sh progname=`/bin/basename $0` /usr/bin/grep something somewhere I picked two quick things that stick in my memory as being particularly problematic. I could find more. That script will actually run on some platforms but will fail miserably on others. There is no guarantee that those particular commands will be in those particular directories and in those two cases there are a lot of variations between different systems. What commands are in which directory depends upon the needs of the individual system. And there isn't any reason to try to force a particular version of those commands. The usage is uninteresting and should work everywhere. Is it stronger because it uses full paths or weaker? I claim weaker because the following would run almost everywhere. #!/bin/sh progname=`basename $0` grep something somewhere The use of full paths in such a context creates problems that wouldn't exist if the commands were called without their full paths. I have spent a lot of professional time stripping full paths in exactly the above context from other people's scripts when porting them from X (pick one of HP-UX, Solaris, IBM AIX, Red Hat, SuSE, Debian) where they were developed to Y (pick a different one). Bob