From 62d40c16e34cc599dd4d257f9ed7acbb69990d6c Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Sun, 1 Oct 2023 19:32:28 -0700 Subject: [PATCH] move src under tmp, use sgit from repo, update .gitignore The `src/` tree has been moved under `tmp/`. The `tmp/src/sgit` tree was removed. Instead the sgit as installed from the [sgit repo](https://github.com/xexyl/sgit/). The .gitignore was sorted and cleared up. --- .gitignore | 19 +- src/sgit/.gitignore | 1 - src/sgit/Makefile | 73 ----- src/sgit/README.md | 310 -------------------- src/sgit/sgit.1 | 244 --------------- src/sgit/sgit.sh | 238 --------------- {src => tmp/src}/Makefile | 2 +- {src => tmp/src}/winner_name/.gitignore | 0 {src => tmp/src}/winner_name/Makefile | 0 {src => tmp/src}/winner_name/winner_name.sh | 0 10 files changed, 9 insertions(+), 878 deletions(-) delete mode 100644 src/sgit/.gitignore delete mode 100644 src/sgit/Makefile delete mode 100644 src/sgit/README.md delete mode 100644 src/sgit/sgit.1 delete mode 100755 src/sgit/sgit.sh rename {src => tmp/src}/Makefile (99%) rename {src => tmp/src}/winner_name/.gitignore (100%) rename {src => tmp/src}/winner_name/Makefile (100%) rename {src => tmp/src}/winner_name/winner_name.sh (100%) diff --git a/.gitignore b/.gitignore index eb8af1dde..9be82fdce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,6 @@ -*.bak -*.bku -*.dSYM -.*.sv[a-z] -.*.sw[a-z] -.su[a-z] +# +# sort with: sort -d -u .DS_Store -.sv[a-z] -.sw[a-z] /NOTES /archive/1984/ /archive/1985/ @@ -35,9 +29,12 @@ /archive/2018/ /archive/2019/ /archive/2020/ -/bugs.html +*.bak /bin -/faq.html +*.bku +*.dSYM iocccsize mkentry -readme.html +.su[a-z] +.*.sv[a-z] +.*.sw[a-z] diff --git a/src/sgit/.gitignore b/src/sgit/.gitignore deleted file mode 100644 index 67af07208..000000000 --- a/src/sgit/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sgit diff --git a/src/sgit/Makefile b/src/sgit/Makefile deleted file mode 100644 index 38fc4666a..000000000 --- a/src/sgit/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env make -# -# sgit - run sed (by default with -i) on one or more globs under git control -# -# The most up to date version of this tool and everything related can be found -# at https://github.com/xexyl/sgit. -# -# - Cody Boone Ferguson / @xexyl -# -# This Makefile was created by Landon Curt Noll. -# -# Share and enjoy! :-) - -############# -# utilities # -############# - -CC= cc -CHMOD= chmod -CP= cp -INSTALL= install -RM= rm -SHELL= bash -SHELLCHECK= shellcheck - -#CFLAGS= -O3 -g3 --pedantic -Wall -Werror -CFLAGS= -O3 -g3 --pedantic -Wall - -###################### -# target information # -###################### - -DESTDIR= ../../bin - -TARGETS= sgit - -###################################### -# all - default rule - must be first # -###################################### - -all: ${TARGETS} - @: - -winner_name: winner_name.sh - ${RM} -f -v $@ - ${CP} -f -v $? $@ - ${CHMOD} +x $@ - - -shellcheck: sgit.sh - @${SHELLCHECK} sgit.sh - -################################################# -# .PHONY list of rules that do not create files # -################################################# - -.PHONY: all configure clean clobber install - -################################### -# standard Makefile utility rules # -################################### - -configure: - @: - -clean: - @: - -clobber: clean - rm -f ${TARGETS} - -install: all - ${INSTALL} -m 0555 ${TARGETS} ${DESTDIR} diff --git a/src/sgit/README.md b/src/sgit/README.md deleted file mode 100644 index 653881fa1..000000000 --- a/src/sgit/README.md +++ /dev/null @@ -1,310 +0,0 @@ -# sgit - run sed on files under git control - -`sgit` runs `sed(1)` on files that are under git control, based on one or more -globs (either a pattern or an exact file name). Running this from a directory -that is not a git repository is an error and any files not under git control in -the directory will not be touched. Depending on the globs specified it might or -might not recurse into subdirectories. That is the shell at work, of course. - -`sgit` is extremely useful because one need not run extra commands to determine -the list of files (which might be very long) and then pass them directly to -`sed(1)`. Since it only acts on files under `git` control you need not worry -about files that are not under git control being touched or even considered. - -You can specify the path to `sed` in case you wish to use a different one. For -instance in macOS if you have GNU sed installed you might want to use that -instead. You can do that with the `-s sed` option. - -If you wish to provide options to `sed` itself you can so with the `sgit -o`. -Note that you **MUST** pass the `-` for short options and the `--` for long -options! In other words use the options like you would with `sed` but prefixing -it with `-o` first. - -This was a stylistic choice but it allows one to quote (which is probably always -preferable) the option arg to pass more than one option instead of having to use -`sgit -o` more than once though you can certainly use the option more than once. -If there's a need for a space then you must quote it. Note that not all options -to `sed` have been tested. - -By default it does **in-place editing and it does NOT backup files**. If you -wish to not edit the file in place (see [examples](#examples) later in this -file) you can use the `sgit -I` option. Note that the `-n` option (`sgit -o -n`) -without `sgit -I` can, depending on the sed commands, empty files! This is -analogous to using both `-n` and `-i` to `sed` which would do in-place editing -without automatic printing of the pattern space. An example is provided later. - -If you wish to provide a backup extension for editing files use `sgit -i`. See -example below. Note that using `-i` overwrites existing backup files and it will -also create or update a file for each file edited. This means that if it ends up -editing 50 files without a backup file (with the extension provided) there will -be 50 new files created. Using this option might be of limited use, of course, -since files under git control can be restored, compared etc. but it's there in -case one wants it. - -See the usage below or run `sgit` by itself (or with the `-h` option) to see the -rest of the options. - -See the section [Script history](#script-history) for more details on the -evolution of the script. - -## Usage - -```sh -usage: sgit [-h] [-V] [-v level] [-x] [-I] [-i extension] [-o sed_option] [-s sed] [-e command] - - -h print help and exit - -V print version and exit - -v level set verbosity level - -x turn on tracing (set -x) - -I disable in place editing - - -i extension set backup extension (default none) - WARNING: sed -i overwrites existing backup files - WARNING: this will create or update a file for each file changed - - -o sed_option append sed option or options to options list - WARNING: use of '-o -n' without '-I', can depending on - sed commands, empty files as if both sed -i and sed -n were - used together - - NOTE: you must pass the '-' for short options and '--' for long options! - NOTE: if you need a space in an option you should quote it! - - -s sed set path to sed - -e command append sed command to list of commands to execute on globs - -sgit version: 0.0.12-1 29-04-2023 -``` - -You **MUST** specify at least one `sed` command and one glob: the `sed` command -by way of the `-e` option (analogous to `sed -e`); anything after the last option -is a glob. You may specify more than one of each. Specify `-e` for each command. -The `sed` commands is an array just like the `sed` options. - - -## A note about the `-i` option and backup extensions - -It works like `sed -i` except that the default behaviour of the script is to use -`-i` just with an empty backup extension (this is required for some versions of -`sed` which force that a backup extension actually be provided with the `-i` -option .. I'm looking at you, BSD/macOS `sed`). - - -## `sgit -i` WARNING: each file edited will result in another file in the working directory - -Of course if you have 50 files that are edited then 50 new files will be -created (or otherwise updated) just like with `sed` itself. - -# `sgit -i` WARNING: this **WILL OVERWRITE EXISTING BACKUP FILES**! - -Please be aware that if a backup file already exists it **WILL** be overwritten! -This is because it uses `sed -i`. - -I won't even try and detect this because it's not how `sed` works and it would -overly complicate the script plus it's almost pointless with `git`. - - -# `sgit -o -n` WARNING: invalid use of `sgit -o -n` can empty files! - -As already noted: because `sed -n` does not print output if you do not use `-I` -and you use substitute or do not print everything you can empty the entire file -or remove much of the file for two examples. For instance **DO NOT** do this: - - -```sh -sgit -o -n -e 's/.//g' sgit -``` - -because it would empty `sgit`! - -## More about options and the tool itself - -A man page exists for this tool with more about the tool and the options. It has -some examples but it might be more useful to see the [Examples](#examples) in -this file instead. To render it: - -```sh -man sgit -``` - -if installed. Otherwise if it's not installed you can do: - -```sh -man ./sgit.1 -``` - - -## Examples - -### Change references (_**IN MEMORY ONLY**_ i.e. WITHOUT in-place editing) of the exact word `sed` (as in `\`) in this file but only show changed lines - -```sh -sgit -I -o -n -e 's/\/used/p' README.md -``` - -### Print out matches of the EXACT word `sed` (as in `\`) in all files under git control from the current working directory - -This is a simpler way of running `git --no-pager grep -h -E '\'|sed -'s/^[0-9]*://g'` which itself might or might not be more complicated than it -needs to be: - -```sh -sgit -I -o -n -e '/\/p' . -``` - -### With tracing enabled, change references of `\` to `used` in this file and save it: - -```sh -sgit -e 's/\/used/g' -x README.md -``` - - -### With tracing enabled, change references of `\` to `used`, duplicating the lines, in this file and save it: - -```sh -sgit -e 's/\/used/p' -x README.md -``` - -## Verbosely (level 1) change references of `\` to `used` in this file and save it: - -```sh -sgit -e 's/\/used/g' -v1 README.md -sgit -e 's/\/used/g' -v 1 README.md -``` - -The two are equivalent but naturally running them in sequence the second one -would not do anything useful. - -## Verbosely (level 3) change references of `\` to `used` in this file with a backup as `README.md.bak` - -```sh -sgit -i.bak -e 's/\/used/g' -v 3 README.md -``` - -With the command you would see something like: - -```sh -debug[2]: sed commands: -e s/\/used/g -debug[2]: looping through all globs -debug[1]: using backup extension: .bak -debug[2]: found glob: 0 -debug[1]: about to run: git ls-files README.md | xargs /opt/local/bin/sed -i".bak" -e s/\/used/g -debug[2]: 0 remaining globs -``` - -Level 2 will not show how many globs remain after each operation. - - -### Verbosely (level 3) change references of `\` back to `sed` in this file with a backup as `README.md.bak` - -```sh -sgit -i.bak -e 's/\/sed/g' -v 3 README.md - -``` - -With that you would see something like: - -```sh -sgit -i.bak -e 's/\/sed/g' -v3 README.md -debug[2]: sed commands: -e s/\/sed/g -debug[2]: looping through all globs -debug[1]: using backup extension: .bak -debug[2]: found glob: 0 -debug[1]: about to run: git ls-files README.md | xargs /opt/local/libexec/gnubin/sed -i".bak" -e s/\/sed/g -debug[2]: 0 remaining globs -``` - -and the example title would look like: - -```markdown -### Verbosely (level 3) change references of `\` back to `sed` in this file with a backup as `README.md.bak` -``` - -## Change `\` to `used` but only if it's on the first line - -```sh -sgit -e '1s/\/used/g' README.md -``` - -Alternatively you could do one of: - - -```sh -sgit -e '1s/\/u&/g' README.md -sgit -e '1s/\(\\)/u\1/g' README.md -``` - -### Change `\` to `gits` but only if it's on the third line - -```sh -sgit -e '3s/\/gits/g' README.md -``` - - -## Installation - -If you wish to install it you may either copy it to a place in your path or if -you have `make` installed you can just run `make install` either as root or via -`sudo` like: - -```sh -sudo make install -``` - -## Limitations - -One that comes to mind is you cannot specify `git ls-files` options but this -could be problematic anyway especially if one were to specify the `-z` option. - -There are probably other limitations but it works well for what I needed. - -## Bugs - -None known but it does not try and determine which files match the patterns. -This would likely greatly complicate the script and is I feel unneeded. - -If you specify invalid `sed` commands obviously there will be problems. If you -specify invalid `sed` options there will possibly be problems as well. - -As below this was originally a hack. - - -## History - -It has been a persistent problem for me that I need to edit files under git -control and `sed` is the obvious way to go about it. - -Working on the [IOCCC mkiocccentry](https://github.com/ioccc-src/mkiocccentry) -and the [IOCCC temporary website](https://github.com/ioccc-src/temp-test-ioccc) -repos (and in particular the latter) is what inspired me to finally do something -about it. The latter repo will eventually be merged into the [IOCCC winner -repo](https://github.com/ioccc-src/winner) which is the actual [IOCCC -website](https://www.ioccc.org). - -### Script history - -This was originally a quick and dirty hack to modify files under git control via -`sed`. It started out with some limitations like the inability to deal with -spaces in `sed` commands, only allowing one command (due to a bug) and it had -terrible efficiency because it ran git ls-files for each `sed` command. - -Now it is much more thorough and is more efficient (though not perfect). It -allows you to specify a path to `sed`, `sed` options and multiple `sed` commands -(though the latter always existed), it can disable in-place editing, you can -backup files if you wish and much more. - -`sgit` version `0.0.9-1 24-04-2023` added support to use the `-o` option more -than once. Not allowing this was an oversight. - - -## Other thoughts - -Pull requests are welcome but I think it's mostly in a good enough state where -this will probably generally not be needed. - -## Dedications - -This is dedicated to the [IOCCC](https://www.ioccc.org), the [IOCCC -judges](https://www.ioccc.org/judges.html) (especially [Landon Curt -Noll](http://www.isthe.com/chongo/) and above all my dear Mum Dianne and my -wonderful cousin Dani. diff --git a/src/sgit/sgit.1 b/src/sgit/sgit.1 deleted file mode 100644 index 64acc4ea8..000000000 --- a/src/sgit/sgit.1 +++ /dev/null @@ -1,244 +0,0 @@ -.\" section 1 man page for sgit -.\" -.\" sgit was written by Cody Boone Ferguson in 2023. -.\" -.\" Dedicated to the IOCCC, the IOCCC judges (especially Landon Curt -.\" Noll) and above all my dear Mum and to my wonderful cousin Dani. -.\" -.TH sgit 1 "01 October 2023" "sgit" "" -.SH NAME -.B sgit -\- run -.BR sed (1) -(by default with -.BR \-i ) -on one or more globs under -.BR git (1) -control -.SH SYNOPSIS -.B sgit -.RB [\| \-h \|] -.RB [\| \-V \|] -.RB [\| \-v -.IR level \|] -.RB [\| \-x \|] -.RB [\| \-I \|] -.RB [\| \-i -.IR extension \|] -.RB [\| \-o -.IR sed_option \|] -.RB [\| \-s -.IR sed \|] -.RB [\| \-e -.IR command \|] -.SH DESCRIPTION -.B sgit -allows one to run -.BR sed (1) -on one or more globs under -.BR git (1) -control. -By default it uses the in-place editing option -.B \-i (WITHOUT A BACKUP EXTENSION!) -but in place editing can be disabled with the -.B \-I -option. -If you wish to specify a backup extension use the -.B \-i -option but be aware that it will create a file for each file modified and it will overwrite any previously made backups. -Of course since it only acts on files under -.BR git (1) -control that shouldn't be a big problem but it is worth noting. -.PP -With the option -.B \-s -you can specify an alternative -.BR sed (1) -to use. -To specify -.BR sed (1) -options use -.BR \-o . -If it requires an option arg or you specify more than one option you need to quote it. -To specify a -.BR sed (1) -command use -.BR \-e . -.PP -If you want shell tracing enabled use the -.B \-x -option. -This is not very useful in most cases but it is good for debugging. -If you want verbose output to see what the script is doing you can specify a debug level with -.BR \-v . -.PP -Any text after the final option is considered a glob. -At least one -.BR sed (1) -command and one glob must be specified. -A glob of -.I . -will match all files under git control from the current working directory. -If you run the command from a directory that is not a -.BR git (1) -repo it is an error. -.SH OPTIONS -.TP -.B \-h -Show help and exit. -.TP -.B \-V -Show version and exit. -.TP -.BI \-v\ level -Set verbosity level. -.TP -.B \-x -Turn on tracing (set \-x) -.TP -.B -I -Disable in place editing -.TP -.BI \-i\ extension -Set backup extension (default none) -.RS -.PP -WARNING: sed \-i overwrites existing backup files -.br -WARNING: this will create or update a file for each file changed -.RE -.TP -.BI \-o\ sed_option -Append -.BR sed (1) -options to options list -.RS -.PP -WARNING: use of -.B \-o \-n -without -.BR \-I , -can depending on -.BR sed (1) -commands, empty files as if both -.BR sed (1) -options -.B \-i -and -.B \-n -were used together -.br -NOTE: you must pass the '-' for short options and '--' for long options! -.br -NOTE: if you need a space in an option you should quote it! -.RE -.TP -.BI \-s\ sed -Set path to -.BR sed (1) -.TP -.BI \-e\ command -Append -.BR sed (1) -command to list of commands to execute on globs -.SH EXIT STATUS -.TP -0 -command succeeded, whether modifying any file or not -.TQ -1 -command not run in a -.BR git (1) -repository -.TQ -2 -.B \-h -and help string printed or -.B \-V -and version string printed -.TQ -3 -invalid command line, invalid option or option missing an argument -.SH NOTES -.PP -This tool was written by Cody Boone Ferguson due to a persistent problem where it was needed to modify with -.BR sed (1) -files but only those under -.BR git (1) -control and with certain globs, without having to first extract the paths and passing them all to -.BR sed (1). -It was finally written when he was helping the judges of the IOCCC, the International Obfuscated C Code Contest. -.SH BUGS -.PP -Cody Boone Ferguson wrote it! :) -.PP -On a more serious note there are no known bugs but if you have an issue with the tool please report it at the GitHub issues page. -You can find it at -.br -.IR . -.SH EXAMPLES -.PP -Change references (\c -.B IN MEMORY ONLY -i.e. \fBWITHOUT in\-place editing\fP\c -) of the exact word -.B sed -(as in \c -.BR \\\\ ) -in the -.B sgit -script to -.B used -but only show changed lines: -.IR -.sp -.RS -.ft B -sgit -I -o -n -e 's/\/used/p' sgit -.ft R -.RE -.PP -Print out matches of the exact word -.B sed -(as in \c -.BR \\\\ ) -in all files under -.BR git (1) -control from the current working directory: -.IR -.sp -.RS -.ft B -sgit -I -o -n -e '/\/p' . -.ft R -.sp -.RE -The above is a simpler way of running: -.IR -.sp -.RS -.ft B -git --no-pager grep -h -E '\'|sed 's/^[0-9]*://g' -.ft R -.RE -.sp -.PP -With tracing enabled, change references of the exact word -.B sed -(as in \c -.BR \\\\ ) -in this file and save it: -.sp -.RS -.ft B -sgit -e 's/\/used/g' -x sgit.1 -.ft R -.RE -.PP -For more examples see the following link: -.IR \ -.SH AUTHOR -Cody Boone Ferguson -.SH SEE ALSO -For additional details including the history, script history and other things about the tool, see: -.IR \ diff --git a/src/sgit/sgit.sh b/src/sgit/sgit.sh deleted file mode 100755 index e2964bc23..000000000 --- a/src/sgit/sgit.sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/env bash -# -# sgit - run sed (by default with -i) on one or more globs under git control -# -# This script allows one to run sed on files under git control, based on globs -# (pattern or exact file name) without having to come up with a list of files -# first and then passing those directly to sed. -# -# It allows for multiple sed commands and multiple globs. By default it uses -i -# to edit the file in place (WITHOUT BACKUP EXTENSION; use sgit -i option if you -# want a backup!) but in place editing can be overridden with the -I option. Use -# -h option to see all the options. The README.md provides much more information -# on the usage of the script and I recommend you look at that. -# -# The options are described in more detail in the man page sgit.1. -# -# For a list of warnings see the usage string and more so the README.md file as -# there are some options that when used together (or an option not used with -# another) can in some cases empty files (depends on command) or one can end up -# creating many additional files (if backing up the files for instance with the -# -i option). -# -# A man page also exists for this tool as sgit.1. -# -# - Cody Boone Ferguson (@xexyl) -# - -export SGIT_VERSION="0.0.12-1 29-04-2023" # format: major.minor.patch-release DD-MM-YYYY - -USAGE="usage: $(basename "$0") [-h] [-V] [-v level] [-x] [-I] [-i extension] [-o sed_option] [-s sed] [-e command] - - -h print help and exit - -V print version and exit - -v level set verbosity level - -x turn on tracing (set -x) - -I disable in place editing - - -i extension set backup extension (default none) - WARNING: sed -i overwrites existing backup files - WARNING: this will create or update a file for each file changed - - -o sed_option append sed option or options to options list - WARNING: use of '-o -n' without '-I', can depending on - sed commands, empty files as if both sed -i and sed -n were - used together - - NOTE: you must pass the '-' for short options and '--' for long options! - NOTE: if you need a space in an option you should quote it! - - -s sed set path to sed - -e command append sed command to list of commands to execute on globs - -sgit version: $SGIT_VERSION" - -SED="$(type -P sed)" -export SED -export I_FLAG= -export VERBOSITY=0 -export EXTENSION="" - -# we need an array for sed commands -declare -a SED_COMMANDS -# we need an array for sed options -declare -a SED_OPTIONS - -# we need to remove ' ' from the IFS! -IFS=$'\t\n' - -# parse args -# -while getopts :hVv:xIi:o:s:e: flag; do - case "$flag" in - h) echo "$USAGE" 1>&2 - exit 2 - ;; - V) echo "$SGIT_VERSION" 1>&2 - exit 2 - ;; - v) VERBOSITY="$OPTARG"; - ;; - x) set -x - ;; - I) I_FLAG="-I" - ;; - i) EXTENSION="$OPTARG" - ;; - o) SED_OPTIONS+=("$OPTARG") - ;; - s) SED="$OPTARG" - ;; - e) SED_COMMANDS+=(-e "$OPTARG") - ;; - \?) echo "$0: ERROR: invalid option: -$OPTARG" 1>&2 - exit 3 - ;; - :) echo "$0: ERROR: option -$OPTARG requires an argument" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 - ;; - *) echo "$0: ERROR: unexpected value from getopts: $flag" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 - ;; - esac -done - -shift $(( OPTIND - 1 )); - -# firewall - -# check that SED_COMMANDS is not empty! -if [[ -z "${SED_COMMANDS[*]}" ]]; then - echo "$(basename "$0"): ERROR: you must specify at least one sed command and one glob" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 -fi - -# check that sed is executable -if [[ -z "$SED" ]]; then - echo "$(basename "$0"): ERROR: sed cannot be empty" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 -elif [[ ! -f "$SED" ]]; then - echo "$(basename "$0"): ERROR: sed is not a regular file: $SED" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 -elif [[ ! -x "$SED" ]]; then - echo "$(basename "$0"): ERROR: sed is not an executable file: $SED" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 -fi - -# also check number of remaining args -if [[ "$#" -eq 0 ]]; then - echo "$(basename "$0"): ERROR: you must specify at least one glob" 1>&2 - echo 1>&2 - echo "$USAGE" 1>&2 - exit 3 -fi - -# then check that this is a git repo! -git status 2>/dev/null 1>&2 -status="$?" -if [[ "$status" -ne 0 ]]; then - echo "$(basename "$0"): ERROR: ${PWD} not a git repository" 1>&2 - exit 1 -fi - -if [[ $VERBOSITY -gt 1 ]]; then - echo "debug[2]: sed commands: ${SED_COMMANDS[*]}" 1>&2 -fi - -# This might not the best performance because it does this on all files of the -# glob rather than only those files matched by the glob with matching text but -# it's better than it used to be (it used to run git ls-files on the repo for -# each sed command so the more you had the slower it would become as it had to -# get the list of files each time!). -# -# A better approach would be to somehow use git grep to find files that match -# but this would complicate the command line (at least in any way I can think of -# how to do it) so we do it on all files in the repo. -# -# But these would possibly require additional args to the command and -# unnecessarily complicate matters. Anyway it's something of a hack so it -# doesn't have to be perfect (not that there even is such a thing as perfect). -# -if [[ "$VERBOSITY" -gt 1 ]]; then - echo "debug[2]: looping through all globs" 1>&2 -fi - -if [[ -n "$EXTENSION" ]]; then - if [[ "$VERBOSITY" -ge 1 ]]; then - echo "debug[1]: using backup extension: $EXTENSION" 1>&2 - fi -fi - -GLOBS="$#" -i=0 -while [[ "$i" -lt "$GLOBS" ]]; do - if [[ "$VERBOSITY" -gt 1 ]]; then - echo "debug[2]: found glob: $i" 1>&2 - fi - - - if [[ "$VERBOSITY" -ge 1 ]]; then - if [[ -z "$I_FLAG" ]]; then - # Determine if any sed options were specified. We only need to know - # if the array is empty or not; we do not need to expand it in the - # check. - # - # SC2128 (warning): Expanding an array without an index only gives the first element. - # shellcheck disable=SC2128 - if [[ -n "$SED_OPTIONS" ]]; then - echo "debug[1]: about to run: git ls-files $1 | xargs $SED -i\"$EXTENSION\" ${SED_OPTIONS[*]} ${SED_COMMANDS[*]}" 1>&2 - else - echo "debug[1]: about to run: git ls-files $1 | xargs $SED -i\"$EXTENSION\" ${SED_COMMANDS[*]}" 1>&2 - fi - else - if [[ -n "$SED_OPTIONS" ]]; then - echo "debug[1]: about to run: git ls-files $1 | xargs $SED ${SED_OPTIONS[*]} ${SED_COMMANDS[*]}" 1>&2 - else - echo "debug[1]: about to run: git ls-files $1 | xargs $SED ${SED_COMMANDS[*]}" 1>&2 - fi - fi - fi - - if [[ -z "$I_FLAG" ]]; then - if [[ -n "$SED_OPTIONS" ]]; then - git ls-files "$1" | xargs "$SED" -i"$EXTENSION" "${SED_OPTIONS[*]}" "${SED_COMMANDS[@]}" - else - git ls-files "$1" | xargs "$SED" -i"$EXTENSION" "${SED_COMMANDS[@]}" - fi - else - if [[ -n "$SED_OPTIONS" ]]; then - git ls-files "$1" | xargs "$SED" "${SED_OPTIONS[*]}" "${SED_COMMANDS[@]}" - else - git ls-files "$1" | xargs "$SED" "${SED_COMMANDS[@]}" - fi - fi - ((i++)) - shift 1 - if [[ "$VERBOSITY" -gt 2 ]]; then - if [[ "$#" -eq 1 ]]; then - echo "debug[2]: $# remaining glob" 1>&2 - else - echo "debug[2]: $# remaining globs" 1>&2 - fi - fi - -done - -exit 0 diff --git a/src/Makefile b/tmp/src/Makefile similarity index 99% rename from src/Makefile rename to tmp/src/Makefile index ac5aa064f..cde17fc94 100644 --- a/src/Makefile +++ b/tmp/src/Makefile @@ -44,7 +44,7 @@ CFLAGS= -O3 -g3 --pedantic -Wall # target information # ###################### -TARGETS= sgit winner_name +TARGETS= winner_name ###################################### # all - default rule - must be first # diff --git a/src/winner_name/.gitignore b/tmp/src/winner_name/.gitignore similarity index 100% rename from src/winner_name/.gitignore rename to tmp/src/winner_name/.gitignore diff --git a/src/winner_name/Makefile b/tmp/src/winner_name/Makefile similarity index 100% rename from src/winner_name/Makefile rename to tmp/src/winner_name/Makefile diff --git a/src/winner_name/winner_name.sh b/tmp/src/winner_name/winner_name.sh similarity index 100% rename from src/winner_name/winner_name.sh rename to tmp/src/winner_name/winner_name.sh