[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/1.4.2.3i |
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?
- Re: [Help-bash] Best way to remove trailing '/' from a path?, (continued)
Re: [Help-bash] Best way to remove trailing '/' from a path?, Stephane Chazelas, 2015/04/20
Re: [Help-bash] Best way to remove trailing '/' from a path?, Stephane Chazelas, 2015/04/20
Re: [Help-bash] Best way to remove trailing '/' from a path?, Chris F.A. Johnson, 2015/04/20
Re: [Help-bash] Best way to remove trailing '/' from a path?, Eric Blake, 2015/04/21