From 7f79cca7bca456f1dc13e12efc5290a89bf457f4 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Thu, 2 Apr 2020 11:19:17 +0100 Subject: [PATCH] scripts/systemd-run-i3: fix overriding unit name systemd-run uses the last passed argument for each flag, so specify the default first, and the override afterwards, if set --- scripts/systemd-run-i3 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/systemd-run-i3 b/scripts/systemd-run-i3 index cf504e7..169b1a8 100755 --- a/scripts/systemd-run-i3 +++ b/scripts/systemd-run-i3 @@ -1,9 +1,11 @@ #!/bin/bash -e +rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 16) + args=() while getopts "u:s:e:d:cnw" opt do case "$opt" in - u) args+=("--unit=$OPTARG");; + u) args+=("--unit=$OPTARG-$rand");; s) args+=("--slice=$OPTARG");; e) args+=("--setenv=$OPTARG");; d) args+=("--working-directory=$OPTARG");; @@ -15,6 +17,4 @@ do case "$opt" in done shift $((OPTIND-1)) -rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 16) - -exec systemd-run --user --collect ${args[@]} --unit="$1-$rand" -- "$@" +exec systemd-run --user --collect --unit="$1-$rand" ${args[@]} -- "$@"