~rootmos/scripts

785b7c93a87efd5d46967546448677de460a42e6 — Gustav Behm a month ago cd4d19f
Add a script to force argv[0] to appear as the basename of an executed executable: for use in the -h output
1 files changed, 21 insertions(+), 0 deletions(-)

A usage
A usage => usage +21 -0
@@ 0,0 1,21 @@
#!/bin/bash

set -o nounset -o pipefail -o errexit

EXE=$1
OUTPUT=${2-/dev/stdout}

TMP=$(mktemp)
trap 'rm -f $TMP' EXIT

python - "$EXE" <<EOF >> "$TMP"
import sys
import os
import subprocess

exe = sys.argv[1]
name = os.path.basename(exe)
subprocess.run([name, "-h"], executable=exe, check=True)
EOF

cp "$TMP" "$OUTPUT"