ohmybash / oh-my-bash

A delightful community-driven framework for managing your bash configuration, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
https://ohmybash.github.io
MIT License
5.53k stars 624 forks source link

Wrong shell expression output #530

Open Michaelzhouisnotwhite opened 4 months ago

Michaelzhouisnotwhite commented 4 months ago

reproduce

# in origin shell:
echo $(cd "${SCRIPT_DIR}";pwd)

the command shows the script current path. However, in oh-my-bash, it shows the same path twice.

output

oh-my-bash: image

origin shell: image

akinomyoga commented 4 months ago

In Oh My Bash, cd is configured to print the new path when it finds the destination directory in the current directory. To turn off this behavior, you can set an empty string to CDPATH:

# bashrc (after source "$OSH"/oh-my-bash.sh)

CDPATH=

Or you can redirect the output of cd in the above case:

echo $(cd "${SCRIPT_DIR}" >/dev/null; pwd)