Thanks for that comment!  I use this as a function inside a script and am not
knowledgable of a way of returning strings via a shell function. Instead I always
use the convention of sticking it in a variable named after the function with a
leading underscore.

Yeah, printing the result is a great idea (and I may use that :), however one
would have to invoke a subshell to get it (using either "`" or eval) I should
think.  It is a bit more costly ... always a trade off when trying to be pure :)

Thanks again,

    - Bruce


rpjday wrote:

> On Sun, 7 May 2000, Bruce A. Mallett wrote:
>
> > While on the PATH manipulation subject, I find the following function
> > handy when using ksh.  It eliminates duplicates in a PATH style string.
> > This is useful when one has a lot of things like:
> >
> >    export PATH="$PATH;/some/new/stuff"
> >
> > These tend to accumulate a lot of duplicate entries which can be eliminated
> > using this function by:
> >
> >    RemoveDups "$PATH"
> >    export PATH="$_RemoveDups"
>
> i'm nervous about the technique of returning arbitrary values from
> functions by assigning those values to a global variable.  an
> alternative technique is to have the function return the value
> by printing it, and getting that value using command substitution:
>
> PATH=$(RemoveDups $PATH)
>
>   the RemoveDups function itself would then, as the last statement,
> simply
>
> print <new path>
>
>   comments?
>
> rday
>
> --
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to