Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Created March 4, 2025 06:15
Show Gist options
  • Save notpushkin/0379568fa3736adc59e6ed227a0cbcdc to your computer and use it in GitHub Desktop.
Save notpushkin/0379568fa3736adc59e6ed227a0cbcdc to your computer and use it in GitHub Desktop.
A shell function that wraps rm and re-orders flags in a way compatible with BSD platforms.
# SPDX-License-Identifier: Unlicense
rm() {
local flags=()
local args=()
for arg in "$@"; do
if [[ $arg == -* ]]; then
flags+=("$arg")
else
args+=("$arg")
fi
done
command rm "${flags[@]}" "${args[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment