mirror of
https://github.com/dylanaraps/pure-bash-bible.git
synced 2025-09-01 03:21:56 +02:00
dirname: fix another case
This commit is contained in:
@@ -1067,10 +1067,9 @@ Alternative to the `dirname` command.
|
||||
dirname() {
|
||||
# Usage: dirname "path"
|
||||
dir=${1%%/}
|
||||
[[ "${dir##*/*}" ]] && dir=.
|
||||
dir=${dir%/*}
|
||||
|
||||
[[ $1 == */* ]] || dir=.
|
||||
|
||||
printf '%s\n' "${dir:-/}"
|
||||
}
|
||||
```
|
||||
|
@@ -10,10 +10,9 @@ Alternative to the `dirname` command.
|
||||
dirname() {
|
||||
# Usage: dirname "path"
|
||||
dir=${1%%/}
|
||||
[[ "${dir##*/*}" ]] && dir=.
|
||||
dir=${dir%/*}
|
||||
|
||||
[[ $1 == */* ]] || dir=.
|
||||
|
||||
printf '%s\n' "${dir:-/}"
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user