Skip to main content
Code Review

Return to Answer

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

200_success's answer uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)
deleted 81 characters in body
Source Link

200_success's answer has one more place to refine: it overrides the global variable $i. And it also uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer has one more place to refine: it overrides the global variable $i. And it also uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)
added 276 characters in body
Source Link

200_success's answer has one more place to refine: it overrides the global variable $i. And it also uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer has one more place to refine: it overrides the global variable $i.

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)

200_success's answer has one more place to refine: it overrides the global variable $i. And it also uses the evil eval which in his context was unnecessary.

Update: Oh, what, ? Let's use some brace expansion + evil things:

# This time we have to be evil. All code in this answer is CC0.
up() { [ "1ドル" -eq "1ドル" ] &>/dev/null || set -- 1; "cd \$(printf '../%.s' {1..1ドル})"; }

local is not a that nice solution since POSIX doesn't contain local. After some searching, I found out that it's possible to use printf to duplicate strings. After replacing the brace expansion with seq, here is what I got:

up() { cd "$(printf '../%.s' $(seq 1 1ドル))"; }

P.S.: The use of seq for simple looping is sometimes considered harmful, especially when used with for var in. To make you feel less guilty:

# integer seq, @copyright CC0.
iseq() (
 : ${iseq_fmt='%s\n'}
 case "$#" in
 (1) i=1 last=1ドル incr=1;;
 (2) i=1ドル last=2ドル incr=1;;
 (3) i=1ドル last=3ドル incr=2ドル;;
 (*) return 2;;
 esac
 [ "$i" -eq "$i" ] && [ "$incr" -eq "$incr" ] && [ "$last" -eq "$last" ] || return 2
 while [ "$i" -le "$last" ]; do
 printf "$iseq_fmt" "$i"
 : $((i = i + incr))
 done
)
added 555 characters in body
Source Link
Loading
Source Link
Loading
lang-bash

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