I’m looking at the source code of virtualenv, and the activate script contains this code:
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
What does the line if [ "x" != x ] do? x is not defined anywhere else in the script.
In Bash, that test is guaranteed to fail;
[ "x" != x ]always returns a non-zero exit status (i.e. “false”), because"x"andxare both the string consisting of the single characterx. (The quotation marks don’t really have any effect in this case.)What’s more, the command
PS1="$PS1"doesn’t really do anything, either: it just sets the variablePS1equal to the value it already has.I’m guessing that this script is autogenerated in some way, and that on some systems, these statements will look a bit different, and a bit less useless.