emanuele6 1669697584 learn cd "$path" is problematic for various reasons 1) it may interpret options because it is missing -- 2) it will look in CDPATH before the current directory if path is missing / 3) if path is -, it will cd to OLDPWD instead of ./- (n.b. even if you use --). you should instead use [ "$path" = - ] && path=./-; CDPATH= cd -- "$path" or, alternatively OLDPWD=$path cd - > /dev/null emanuele6 1669697661 forget emanuele6 1669697683 learn cd "$path" is problematic for various reasons 1) it may interpret options because it is missing -- 2) it will look in CDPATH before the current directory if path is missing / 3) if path is -, it will cd to OLDPWD instead of ./- (n.b. even if you use --). you should instead use [ "$path" = - ] && path=./-; CDPATH= cd -- "$path" or, alternatively OLDPWD=${path:-.} cd - > /dev/null emanuele6 1669708118 forget emanuele6 1669708568 learn cd "$path" is problematic for various reasons 1) it may interpret path as an option 2) it will look for the directory in CDPATH before PWD if path does not start with ./, ../ or / 3) if path is -, it will cd to OLDPWD instead of ./- (n.b. even if you use --). You could instead use [ "$path" = - ] && path=./-; CDPATH= cd -- "$path" or OLDPWD=${path:-.} cd - > /dev/null emanuele6 1669708724 forget emanuele6 1669708837 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is -, it will cd to OLDPWD instead of ./- (n.b. even if you use --). You could instead use [[ $dir = [!/]* ]] && dir=./$dir; CDPATH= cd -- "$dir" or OLDPWD=${dir:-.} cd - > /dev/null emanuele6 1669709357 forget emanuele6 1669709451 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is -, it will cd to OLDPWD instead of ./- (n.b. even if you use --). You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir" or CDPATH= cd -- "${dir/#-/./-}" or OLDPWD=${dir:-.} emanuele6 1669709470 forget emanuele6 1669709512 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is "-", it will cd to OLDPWD instead of ./- You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir" or CDPATH= cd -- "${dir/#-/./-}" or OLDPWD=${dir:-.} cd - > /dev/null emanuele6 1669711741 forget emanuele6 1669711761 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is "-", it will cd to OLDPWD instead of ./- You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir" or CDPATH= cd -- "${dir/#-/./-}" or OLDPWD=${dir:-.}; cd - > /dev/null emanuele6 1669714796 forget emanuele6 1669714863 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is "-", it will cd to OLDPWD instead of ./- You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir" or simply HOME=$dir cd emanuele6 1669714907 forget emanuele6 1669714915 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is "-", it will cd to OLDPWD instead of ./- You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir" or simply HOME=${dir:-.} cd emanuele6 1676501721 forget emanuele6 1676501751 learn cd "$dir" is problematic for various reasons 1) it may interpret dir as an option 2) it will look for the directory in CDPATH before PWD if dir does not start with ./, ../ or / 3) if dir is "-", it will cd to OLDPWD instead of ./- You could instead use [ "$dir" = - ] && dir=./-; CDPATH= cd -- "$dir"