8000 [Feature] uninstall rm -rf directory safety check · Issue #14 · NomenAK/SuperClaude · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Feature] uninstall rm -rf directory safety check #14
Closed
@k33bs

Description

@k33bs

Feature Type

Installation/Setup

Problem Description

Looks like this would rm -rf your root without checking or asking, might want to build in a simple sanity check :)

DO NOT EXECUTE THIS:
./install.sh --uninstall --dir /

Proposed Solution

# Resolve the path to its real, absolute form to prevent tricks like /opt/../
# The -m flag allows it to work even if the path doesn't exist yet.
INSTALL_DIR_RESOLVED=$(realpath -m "$INSTALL_DIR")

# Calculate the depth of the path. A path like /home/user is depth 2.
# We remove the leading slash, then count the remaining slashes, and add 1.
# Or an easier way: count non-empty components.
PATH_DEPTH=$(echo "$INSTALL_DIR_RESOLVED" | tr -s '/' | grep -o '/' | wc -l)

# For safety, require a minimum path depth.
# Depth 1 = /foo, Depth 2 = /foo/bar. We'll require at least depth 1.
# And explicitly forbid the root directory itself (depth 0).
MIN_DEPTH=2

if [[ "$INSTALL_DIR_RESOLVED" == "/" ]] || [[ $PATH_DEPTH -lt $MIN_DEPTH ]]; then
    echo -e "${RED}Error: Invalid or dangerous directory specified: '$INSTALL_DIR'${NC}"
    echo "For safety, the installation path must not be the root directory ('/') or a top-level directory."
    echo "Please specify a nested path like '$HOME/.claude' or '/opt/claude'."
    exit 1
fi

Should probably also ask y/n if it selected the right directly before executing rm -rf.

Alternative Solutions

No response

Use Cases

Safety against typos and copy pastes gone wrong.

Examples

No response

Priority

Nice to have

Additional Context

No response

Checklist

  • I have searched for existing feature requests
  • I have provided a clear use case
  • I'm willing to help test this feature
  • I'm willing to help implement this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0