Skip to main content
Code Review

Return to Answer

eval is superfluous (thanks, @Arthur2e5)
Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479

Your recommendation is to define alias up=". path/to/up" so that when you type up 3, it expands to . up 3. However, since you want to take an optional argument and affect the state of the current shell, I think you would be better off defining a shell function instead.

As it turns out, the [ -z "1ドル" ] special case is not necessary, since seq 1 just expands to 1.

You end up executing n separate cd .. commands for up n. This leads to a usability bug: cd - or cd $OLDPWD, which normally take you back to the previous directory, don't work the way I expect.

Suggested solution:

up() {
 eval cd $(for i in $(seq 1 1ドル) ; do echo -n ../ ; done)
}

Your recommendation is to define alias up=". path/to/up" so that when you type up 3, it expands to . up 3. However, since you want to take an optional argument and affect the state of the current shell, I think you would be better off defining a shell function instead.

As it turns out, the [ -z "1ドル" ] special case is not necessary, since seq 1 just expands to 1.

You end up executing n separate cd .. commands for up n. This leads to a usability bug: cd - or cd $OLDPWD, which normally take you back to the previous directory, don't work the way I expect.

Suggested solution:

up() {
 eval cd $(for i in $(seq 1 1ドル) ; do echo -n ../ ; done)
}

Your recommendation is to define alias up=". path/to/up" so that when you type up 3, it expands to . up 3. However, since you want to take an optional argument and affect the state of the current shell, I think you would be better off defining a shell function instead.

As it turns out, the [ -z "1ドル" ] special case is not necessary, since seq 1 just expands to 1.

You end up executing n separate cd .. commands for up n. This leads to a usability bug: cd - or cd $OLDPWD, which normally take you back to the previous directory, don't work the way I expect.

Suggested solution:

up() {
 cd $(for i in $(seq 1 1ドル) ; do echo -n ../ ; done)
}
Source Link
200_success
  • 145.6k
  • 22
  • 190
  • 479

Your recommendation is to define alias up=". path/to/up" so that when you type up 3, it expands to . up 3. However, since you want to take an optional argument and affect the state of the current shell, I think you would be better off defining a shell function instead.

As it turns out, the [ -z "1ドル" ] special case is not necessary, since seq 1 just expands to 1.

You end up executing n separate cd .. commands for up n. This leads to a usability bug: cd - or cd $OLDPWD, which normally take you back to the previous directory, don't work the way I expect.

Suggested solution:

up() {
 eval cd $(for i in $(seq 1 1ドル) ; do echo -n ../ ; done)
}
lang-bash

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