Last active
April 3, 2025 09:43
-
-
Save kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c to your computer and use it in GitHub Desktop.
1password CLI の op run を、引数でもインジェクション出来るようにするラッパースクリプト。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 1Password CLI の op run を、引数でもインジェクション出来るようにするラッパースクリプト。 | |
# https://gist.github.com/kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c | |
op_args=() | |
while (( 0 < $# )); do | |
a=$1 | |
shift | |
op_args+=("$a") | |
[[ $a == -- ]] && break | |
done | |
if [[ $# != 0 ]]; then | |
i=1 | |
prefix="OPRUN$(openssl rand -hex 10)" | |
script="exec" | |
for a in "$@"; do | |
k="$prefix$((i++))" | |
eval "export $k=$(printf %q "$a")" | |
script+=" \"\$$k\"" | |
done | |
op_args+=( bash -c "$script" ) | |
fi | |
exec op run "${op_args[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment