mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
997761878c
* Add module to manipulate KDE config files using kwriteconfig * Fix license issues * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Add smeso as kdeconfig.py maintainer * Fix attributes fragment name * Fix test * Do not use shutil.chown It isn't available on old Python versions * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
38 lines
888 B
Bash
Executable file
38 lines
888 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# Copyright (c) 2023, Salvatore Mesoraca <s.mesoraca16@gmail.com>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
# This script is not supposed to correctly emulate
|
|
# kwriteconf output format.
|
|
# It only tries to emulate its behaviour from the
|
|
# point of view of the Ansible module.
|
|
# Which is: write something that depends on the arguments
|
|
# to the output file, unless we already wrote that before.
|
|
|
|
set -e
|
|
|
|
args=""
|
|
prev_was_file=0
|
|
for var in "$@"; do
|
|
if [ $prev_was_file -eq 1 ]; then
|
|
fname="$var"
|
|
prev_was_file=0
|
|
else
|
|
args="$args $var"
|
|
fi
|
|
if [ "$var" = "--file" ]; then
|
|
prev_was_file=1
|
|
fi
|
|
done
|
|
|
|
if [ "x$fname" = "x" ]; then
|
|
exit 1
|
|
fi
|
|
|
|
if [ -e "$fname" ]; then
|
|
grep -qF "$args" "$fname" && exit 0
|
|
fi
|
|
|
|
echo "$args" >> "$fname"
|