From 4cfa7ed76b24fd3d7162293d1d5a10ed75c5ce39 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Fri, 26 Dec 2025 00:01:52 +0200 Subject: [PATCH 1/2] Add input validation - the script only supports editing a single file --- .local/bin/run0edit | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.local/bin/run0edit b/.local/bin/run0edit index 0909e39..279f419 100755 --- a/.local/bin/run0edit +++ b/.local/bin/run0edit @@ -54,6 +54,12 @@ clean_tempfiles() { rm --force "${tempfile}" "${tempfile}.orig" } +if [ "$#" -ne "1" ]; then + echo "Expected exactly one input file. Usage:" 1>&2 + echo " $0 FILE" 1>&2 + exit 1; +fi + editor_cmd="$(default_editor)" echo "Editing using the command \"${editor_cmd}\"" From 36d1221256009ba65b7ea74b68516f3f8434939c Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Fri, 26 Dec 2025 00:02:44 +0200 Subject: [PATCH 2/2] Parse flag-like inputs as literal names --- .local/bin/run0edit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.local/bin/run0edit b/.local/bin/run0edit index 279f419..8a8b033 100755 --- a/.local/bin/run0edit +++ b/.local/bin/run0edit @@ -30,7 +30,7 @@ make_editable_copy() { orig_file="$1" tempfile="$2" - try_command cp "${orig_file}" "${tempfile}" + try_command cp -- "${orig_file}" "${tempfile}" } elevate_permissions() { @@ -45,13 +45,13 @@ update_file() { tempfile="$1" orig_file="$2" - try_command mv --force "${tempfile}" "${orig_file}" + try_command mv --force -- "${tempfile}" "${orig_file}" } clean_tempfiles() { tempfile="$1" - rm --force "${tempfile}" "${tempfile}.orig" + rm --force -- "${tempfile}" "${tempfile}.orig" } if [ "$#" -ne "1" ]; then