[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Best way to remove trailing '/' from a path?

From: Greg Wooledge
Subject: Re: [Help-bash] Best way to remove trailing '/' from a path?
Date: Tue, 21 Apr 2015 08:07:14 -0400
User-agent: Mutt/

On Mon, Apr 20, 2015 at 10:43:36PM +0100, Stephane Chazelas wrote:
> I think the question was clear enough: remove the trailing
> slashes, but turn "////" into "/" instead of "" as ${VAR%%+(/)}
> would (though as Eric pointed out, one may want *not* to turn
> "//" into "/" as "//" and "/" are different paths on some
> systems).

[[ $var = // ]] || var=${var%%+(/)}
[[ $var = "" ]] && var=/

What do we do with an empty input?  This code turns "" into / which may
or may not be what's desired.

I still think you may be projecting your own (and Eric's) intent onto
the original poster's question, though.  Who knows what crazy desires
lie in his heart?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]