#!/bin/bash
function cd() {
CD_PATH="$(history | tail -1 | sed -e "s,.*${FUNCNAME[0]}\s*,,g")"
if [ -z "${CD_PATH}" -o "${CD_PATH}" = "~" ]; then
CD_PATH="${HOME}"
fi
builtin cd "$(cygpath "$CD_PATH")"
}
#!/bin/bash
TBDIR="/cygdrive/c/Program\ Files\ \(x86\)/MyDir/"
if [ -d "${TBDIR}" ]; then
echo "Found MyDir directory at: ${TBDIR}"
cd "$TBDIR"
else
echo "MyDir program directory not found!"
echo "Wrong DIR path: ${TBDIR}"
exit 1
fi
但这确实有效:
#!/bin/bash
# Cygwin-ism: No quotes!
TBDIR=/cygdrive/c/Program\ Files\ \(x86\)/MyDir/
if [ -d "${TBDIR}" ]; then
...