From 915faab9c074a0a30b8321c3836d0b35f475e94d Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Fri, 29 Apr 2022 14:58:55 +0200 Subject: Use proper .bash suffix --- basic.sh | 102 --------------------------------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 basic.sh (limited to 'basic.sh') diff --git a/basic.sh b/basic.sh deleted file mode 100644 index 5dc475f..0000000 --- a/basic.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2018 Einhard Leichtfuß -# -# basic.sh - script containing the array of the to be generated dictionary's -# names and some common functionality, mostly wrapping sed. -# -# Copyright 2018 Einhard Leichtfuß -# -# This file is part of aur-fd-scripts -# -# aur-fd-scripts is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# aur-fd-scripts is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with aur-fd-scripts. If not, see . -# - -# All methods operate on the file "$tmp". - - -script_path="$(realpath "$0")" -script_dir="${script_path%/*}" - -. "${script_dir}/general-config.sh" || exit 1 -. "${script_dir}/user-config.sh" || exit 1 - - -function init -{ - tmp_d="$(mktemp -d)" - tmp="$tmp_d/a" - tmp_="$tmp_d/b" -} - -# $1: file to treat as input: filename -# requires: init to be run -function input -{ - cp "$1" "$tmp" -} - -# $1: file to write to: filename -# requires: init and input to be run -function write -{ - cp "$tmp" "$1" -} - -function cleanup -{ - rm -rf "$tmp_d" -} -trap cleanup EXIT - -# $1: string to replace: extended regular expression -# $2: string to replace with: sed replacement string -function replace -{ - sed -Ei "s/${1}/${2}/g" "$tmp" -} - -# Replace line by a string (possibly including newlines). -# $1 line to replace: extended regular expression -# $2 text to replace with: (newline terminated) sed replacement string -# $3 removal type: (rm-plus-one|normal) -# `- If $2 is empty, whether to remove only that line or also the one -# following. -function replace_line -{ - if test -n "$2" - then - printf '%s' "$2" > "$tmp_" - - sed -Ei " - /${1}/ { - r $tmp_ - d - } - " "$tmp" - else - if [[ "$3" == rm-plus-one ]] - then - sed -Ei "/${1}/,+1 d" "$tmp" - else - sed -Ei "/${1}/ d" "$tmp" - fi - fi -} - -# $1 line to delete: extended regular expression -function delete_line -{ - sed -Ei "/${1}/ d" "$tmp" -} -- cgit v1.2.3