Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanaraps committed Sep 19, 2019
1 parent 968a1bd commit 27c4d36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,11 @@ dirname() {
# Usage: dirname "path"
dir=${1:-.}
dir=${dir%%${dir##*[!/]}}
[[ "${dir##*/*}" ]] && dir=.
dir=${dir%/*}
dir=${dir%%${dir##*[!/]}}
printf '%s\n' "${dir:-/}"
}
Expand Down
3 changes: 3 additions & 0 deletions manuscript/chapter5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ dirname() {
# Usage: dirname "path"
dir=${1:-.}
dir=${dir%%${dir##*[!/]}}

[[ "${dir##*/*}" ]] && dir=.

dir=${dir%/*}
dir=${dir%%${dir##*[!/]}}

printf '%s\n' "${dir:-/}"
}
Expand Down
6 changes: 6 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ test_dirname() {

result="$(dirname "something/////////////////////")"
assert_equals "$result" "."

result="$(dirname "something/////////////////////a")"
assert_equals "$result" "something"

result="$(dirname "something//////////.///////////")"
assert_equals "$result" "something"
}

test_basename() {
Expand Down

0 comments on commit 27c4d36

Please sign in to comment.