Fix trace eraser execution order - clean history before directory removal
Changes: - Move bash history cleaning BEFORE directory removal prompt - Ensures history is always cleaned regardless of directory choice - Remove exit 0 that was skipping history cleaning Issue: - When user answered "yes" to remove directory, script exited immediately - History cleaning code never executed (was after exit 0) - User's curl commands remained in ~/.bash_history Solution: - Restructure: clean history first, then ask about directory - History cleaning always runs now Tested: ✓ History cleaning happens before directory prompt ✓ Works whether user keeps or removes directory
This commit is contained in:
@@ -115,32 +115,9 @@ rm -f "$SCRIPT_DIR/.sysref" 2>/dev/null
|
||||
rm -f "$SCRIPT_DIR/.sysref.timestamp" 2>/dev/null
|
||||
echo " ✓ Reference database removed"
|
||||
|
||||
# Offer to remove the entire toolkit
|
||||
echo ""
|
||||
echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}"
|
||||
echo "This will delete: $SCRIPT_DIR"
|
||||
echo ""
|
||||
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
||||
|
||||
if [ "$remove_dir" = "yes" ]; then
|
||||
echo ""
|
||||
echo "Removing toolkit directory..."
|
||||
cd /root
|
||||
rm -rf "$SCRIPT_DIR"
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
||||
echo ""
|
||||
echo "All traces have been erased."
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ History and logs cleaned${NC}"
|
||||
echo ""
|
||||
echo "Toolkit directory remains at: $SCRIPT_DIR"
|
||||
echo "You can manually remove it later with: rm -rf $SCRIPT_DIR"
|
||||
fi
|
||||
|
||||
# Final step: Clean bash history (done last to capture all script commands)
|
||||
# Clean bash history BEFORE asking about directory removal
|
||||
# (This ensures history is cleaned even if user removes toolkit directory)
|
||||
CLEAN_HISTORY=true
|
||||
if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then
|
||||
echo ""
|
||||
echo "→ Final cleanup: Removing bash history..."
|
||||
@@ -197,6 +174,30 @@ if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then
|
||||
echo " or simply logout/login to start completely fresh."
|
||||
fi
|
||||
|
||||
# Offer to remove the entire toolkit (AFTER history cleaning)
|
||||
echo ""
|
||||
echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}"
|
||||
echo "This will delete: $SCRIPT_DIR"
|
||||
echo ""
|
||||
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
||||
|
||||
if [ "$remove_dir" = "yes" ]; then
|
||||
echo ""
|
||||
echo "Removing toolkit directory..."
|
||||
cd /root
|
||||
rm -rf "$SCRIPT_DIR"
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
||||
echo ""
|
||||
echo "All traces have been erased."
|
||||
else
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ History and logs cleaned${NC}"
|
||||
echo ""
|
||||
echo "Toolkit directory remains at: $SCRIPT_DIR"
|
||||
echo "You can manually remove it later with: rm -rf $SCRIPT_DIR"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "All traces removed. The trace eraser commands will also be"
|
||||
echo "removed when you log out or start a new shell session."
|
||||
|
||||
Reference in New Issue
Block a user