mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
fix(uninstaller): use -- to prevent option injection on rm/mv
OMZ_DIR is derived from user-controlled environment variables ($ZSH, $ZDOTDIR). If a value begins with -, rm/mv could interpret it as an option flag. Using -- terminates option parsing per POSIX. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
01e779a4d3
commit
7d620c6577
1 changed files with 3 additions and 3 deletions
|
|
@ -61,20 +61,20 @@ fi
|
||||||
|
|
||||||
echo "Removing $OMZ_DIR"
|
echo "Removing $OMZ_DIR"
|
||||||
if [ -d "$OMZ_DIR" ]; then
|
if [ -d "$OMZ_DIR" ]; then
|
||||||
rm -rf "$OMZ_DIR"
|
rm -rf -- "$OMZ_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$zdot/.zshrc" ]; then
|
if [ -e "$zdot/.zshrc" ]; then
|
||||||
ZSHRC_SAVE="$zdot/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)"
|
ZSHRC_SAVE="$zdot/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)"
|
||||||
echo "Found $zdot/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
echo "Found $zdot/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
||||||
mv "$zdot/.zshrc" "${ZSHRC_SAVE}"
|
mv -- "$zdot/.zshrc" "${ZSHRC_SAVE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Looking for original zsh config..."
|
echo "Looking for original zsh config..."
|
||||||
ZSHRC_ORIG="$zdot/.zshrc.pre-oh-my-zsh"
|
ZSHRC_ORIG="$zdot/.zshrc.pre-oh-my-zsh"
|
||||||
if [ -e "$ZSHRC_ORIG" ]; then
|
if [ -e "$ZSHRC_ORIG" ]; then
|
||||||
echo "Found $ZSHRC_ORIG -- Restoring to $zdot/.zshrc"
|
echo "Found $ZSHRC_ORIG -- Restoring to $zdot/.zshrc"
|
||||||
mv "$ZSHRC_ORIG" "$zdot/.zshrc"
|
mv -- "$ZSHRC_ORIG" "$zdot/.zshrc"
|
||||||
echo "Your original zsh config was restored."
|
echo "Your original zsh config was restored."
|
||||||
else
|
else
|
||||||
echo "No original zsh config found"
|
echo "No original zsh config found"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue