42 lines
1.5 KiB
Bash
Executable File
42 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# fake-icfs_dialogue: script that mocks the behavior of icfs_dialogue based on the ./.fake-icfs_dialogue-response file
|
|
|
|
ICFS_DIALOGUE_YES=0
|
|
ICFS_DIALOGUE_NO=1
|
|
ICFS_DIALOGUE_PERM=2
|
|
|
|
if [[ $1 == "--set-fake-response" ]]; then
|
|
#someone knows we are fake :)
|
|
echo "$2" >~/.fake_icfs_dialogue_response
|
|
elif [[ $1 == "--set-fake-response-filename" ]]; then
|
|
echo "$2" >~/.fake_icfs_dialogue_response_filename
|
|
elif [[ $1 == "--reset-fake-response" ]]; then
|
|
rm ~/.fake_icfs_dialogue_response ~/.fake_icfs_dialogue_response_filename
|
|
else
|
|
if [ -f ~/.fake_icfs_dialogue_response ]; then
|
|
FAKE_ICFS_DIALOGUE_RESPONSE=$(cat ~/.fake_icfs_dialogue_response)
|
|
|
|
if [[ -f ~/.fake_icfs_dialogue_response_filename ]]; then
|
|
FAKE_ICFS_DIALOGUE_RESPONSE_FILENAME=$(cat ~/.fake_icfs_dialogue_response_filename)
|
|
if [[ $FAKE_ICFS_DIALOGUE_RESPONSE_FILENAME == "" ]]; then
|
|
printf "%s" "$4"
|
|
else
|
|
printf "%s" "$(cat ~/.fake_icfs_dialogue_response_filename)"
|
|
fi
|
|
fi
|
|
|
|
if [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "yes" ]]; then
|
|
exit "$ICFS_DIALOGUE_YES"
|
|
elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "no" ]]; then
|
|
exit "$ICFS_DIALOGUE_NO"
|
|
elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "yes_perm" ]]; then
|
|
exit "$((ICFS_DIALOGUE_YES | ICFS_DIALOGUE_PERM))"
|
|
elif [[ $FAKE_ICFS_DIALOGUE_RESPONSE == "no_perm" ]]; then
|
|
exit "$((ICFS_DIALOGUE_NO | ICFS_DIALOGUE_PERM))"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
exit 255 # TODO: call actual icfs_dialogue here
|