Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/kdeconfig/tasks/files/kwriteconf_fake

raw
1 #!/bin/sh
2
3 # Copyright (c) 2023, Salvatore Mesoraca <[email protected]>
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 # This script is not supposed to correctly emulate
8 # kwriteconf output format.
9 # It only tries to emulate its behaviour from the
10 # point of view of the Ansible module.
11 # Which is: write something that depends on the arguments
12 # to the output file, unless we already wrote that before.
13
14 set -e
15
16 args=""
17 prev_was_file=0
18 for var in "$@"; do
19 if [ $prev_was_file -eq 1 ]; then
20 fname="$var"
21 prev_was_file=0
22 else
23 args="$args $var"
24 fi
25 if [ "$var" = "--file" ]; then
26 prev_was_file=1
27 fi
28 done
29
30 if [ "x$fname" = "x" ]; then
31 exit 1
32 fi
33
34 if [ -e "$fname" ]; then
35 grep -qF "$args" "$fname" && exit 0
36 fi
37
38 echo "$args" >> "$fname"