]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-sudo.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / lib-sudo.sh
CommitLineData
b9063afd
CMAB
1# Helpers for running git commands under sudo.
2
3# Runs a scriplet passed through stdin under sudo.
4run_with_sudo () {
5 local ret
6 local RUN="$TEST_DIRECTORY/$$.sh"
7 write_script "$RUN" "$TEST_SHELL_PATH"
8 # avoid calling "$RUN" directly so sudo doesn't get a chance to
9 # override the shell, add aditional restrictions or even reject
10 # running the script because its security policy deem it unsafe
11 sudo "$TEST_SHELL_PATH" -c "\"$RUN\""
12 ret=$?
13 rm -f "$RUN"
14 return $ret
15}