Skip to main content
Code Review

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

The discussion in the comments of this answer this answer made me wonder how hard it would be to write a built-in only version of dirname.

The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname.

The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname.

added 79 characters in body
Source Link

Update: Made a gist .

Update: Made a gist .

Tweeted twitter.com/#!/StackCodeReview/status/639217898922344448
Update for local script changes (no effect on actual code).
Source Link
#!/bin/sh
p=1ドル
alt=2ドル
skip78=
stripslashes() {
 i=1ドル
 while [ "$i" != "$o" ]; do
 o=$i
 i=${i%/}
 done
 eval "2ドル=\$i"
}
[ "$p" = '//' ] || {
 case "$p" in
 *[!/]*|'')
 stripslashes "$p" p
 case "$p" in
 */*)
 p=${p%/*}
 ;;
 *)
 p=.
 skip78=skip78
 ;;
 esac
 ;;
 *)
 p=/
 skip78=skip78
 ;;
 esac
}
[ -n "$skip78" ] || {
 { [ "$p" != '//' ] || [ -nz "2ドル""$alt" ]; } && {
 stripslashes "$p" p
 [ -z "$p" ] && p=/
 }
}
printf -- %s\\n "$p"
#!/bin/sh
p=1ドル
skip78=
stripslashes() {
 i=1ドル
 while [ "$i" != "$o" ]; do
 o=$i
 i=${i%/}
 done
 eval "2ドル=\$i"
}
[ "$p" = '//' ] || {
 case "$p" in
 *[!/]*|'')
 stripslashes "$p" p
 case "$p" in
 */*)
 p=${p%/*}
 ;;
 *)
 p=.
 skip78=skip78
 ;;
 esac
 ;;
 *)
 p=/
 skip78=skip78
 ;;
 esac
}
[ -n "$skip78" ] || {
 { [ "$p" != '//' ] || [ -n "2ドル" ]; } && {
 stripslashes "$p" p
 [ -z "$p" ] && p=/
 }
}
printf -- %s\\n "$p"
#!/bin/sh
p=1ドル
alt=2ドル
skip78=
stripslashes() {
 i=1ドル
 while [ "$i" != "$o" ]; do
 o=$i
 i=${i%/}
 done
 eval "2ドル=\$i"
}
[ "$p" = '//' ] || {
 case "$p" in
 *[!/]*|'')
 stripslashes "$p" p
 case "$p" in
 */*)
 p=${p%/*}
 ;;
 *)
 p=.
 skip78=skip78
 ;;
 esac
 ;;
 *)
 p=/
 skip78=skip78
 ;;
 esac
}
[ -n "$skip78" ] || {
 { [ "$p" != '//' ] || [ -z "$alt" ]; } && {
 stripslashes "$p" p
 [ -z "$p" ] && p=/
 }
}
printf -- %s\\n "$p"
added 40 characters in body
Source Link
Ethan Bierlein
  • 15.9k
  • 4
  • 60
  • 146
Loading
fixed link; edited tags
Source Link
200_success
  • 145.5k
  • 22
  • 190
  • 479
Loading
Source Link
Loading
lang-bash

AltStyle によって変換されたページ (->オリジナル) /