nicowilliams / inplace

Stream editor adaptor for in-place editing
46 stars 3 forks source link

License #7

Open 0mp opened 2 years ago

0mp commented 2 years ago

What is the inplace's license? I couldn't find any mention if this little program is open-source or not.

milahu commented 2 years ago

this little program

its so simple i can write it in 10 lines of bash

#!/bin/sh
# inplace.sh
# Stream editor adaptor for in-place editing
# based on https://github.com/nicowilliams/inplace
# example use:
# $ inplace somefile sed -e 's/foo/bar/g'
# license: MIT. copyright (c) 2022 Milan Hauth
set -e
#set -x # debug
[ "$#" = 0 ] && { echo "inplace: usage: inplace [-b .bak] file.txt sed 's/a/b/'" >&2; exit 1; }
b=""; if [ "$1" = "-b" ]; then shift; b="$1"; shift; fi
f="$1"; shift
[ -n "$1" ] || { echo "inplace: missing argument: command" >&2; exit 1; }
t=$(mktemp)
# command is in $@
cat "$f" | "$@" >"$t" || { rc=$?; echo "inplace: command failed" >&2; exit $rc; }
[ -n "$b" ] && printf "inplace: backup " >&2; cp -v "$f" "$f$b" >&2
mv "$t" "$f"
$ ./inplace.sh -b .bak foo.txt sed 's/a/b/' 
inplace: backup 'foo.txt' -> 'foo.txt.bak'

stuff like this should not even qualify for copyright, should be public domain by default

maybe ask moreutils to implement inplace (moreutils also has sponge)