summaryrefslogtreecommitdiff
path: root/tests/fake-editor-change-password.sh
blob: 7d30bdb9dd9a9f1378ddd5018f7c89f0385f55bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# Fake editor program for testing 'pass edit'.
# Changes password to 'Hello World', leaving rest of file intact.
#
# Intended use:
#   export FAKE_EDITOR_PASSWORD="blah blah blah"
#   export EDITOR=fake-editor-change-password.sh
#   $EDITOR <password file>
#
# Arguments: <filename>
# Returns: 0 on success, 1 on error

if [[ $# -ne 1 ]]; then
	echo "Usage: $0 <filename>"
	exit 1
fi

filename=$1 ; shift ;
new_password="${FAKE_EDITOR_PASSWORD:-Hello World}"

# And change only first line of file
# -i.tmp allows editing file in place. Extension needed on Mac OSX
sed -i.tmp "1 s/^.*$/$new_password/g" "$filename"

exit 0
td> 2018-06-10[zsh] Remove obsolete isabelle functionsRené 'Necoro' Neumann2-112/+0 2018-06-10Misc changesRené 'Necoro' Neumann3-0/+7 2018-06-10[git] Update email addressRené 'Necoro' Neumann1-1/+1 2018-06-10Enhance cci scriptRené 'Necoro' Neumann1-15/+12 2017-11-18Some windows setupRené 'Necoro' Neumann2-1/+6 2017-10-08[zsh] Use zcalc instead of bcRené 'Necoro' Neumann1-5/+4 2017-10-08[zsh] CalculatorRené 'Necoro' Neumann1-0/+8 2017-10-08Some vim changes.René 'Necoro' Neumann4-28/+17 2017-10-08Delete old stuff.René 'Necoro' Neumann5-71/+1