aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/README.md b/README.md
index ec7285b..638e4d5 100644
--- a/README.md
+++ b/README.md
@@ -512,8 +512,11 @@ Alternative to the `basename` command.
```sh
basename() {
# Usage: basename "path"
- path=${1%/}
- printf '%s\n' "${path##*/}"
+ dir=${1%${1##*[!/]}}
+ dir=${dir##*/}
+ dir=${dir%"$2"}
+
+ printf '%s\n' "${dir:-/}"
}
```