applets_sh/*: Add a few more examples of "shell applets"
authorPere Orga <gotrunks@gmail.com>
Thu, 9 Feb 2012 17:23:33 +0000 (18:23 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 9 Feb 2012 17:23:33 +0000 (18:23 +0100)
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
applets_sh/README [new file with mode: 0644]
applets_sh/dos2unix [new file with mode: 0755]
applets_sh/tac [new file with mode: 0755]
applets_sh/unix2dos [new file with mode: 0755]

diff --git a/applets_sh/README b/applets_sh/README
new file mode 100644 (file)
index 0000000..9dcd38a
--- /dev/null
@@ -0,0 +1,5 @@
+This directory contains examples of applets implemented as shell scripts.
+
+So far these scripts are not hooked to the build system and are not
+installed by "make install". If you want to use them,
+you need to install them by hand.
diff --git a/applets_sh/dos2unix b/applets_sh/dos2unix
new file mode 100755 (executable)
index 0000000..0fd5206
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# TODO: use getopt to avoid parsing options as filenames,
+# and to support -- and --help
+[ $# -ne 0 ] && DASH_I=-i
+sed $DASH_I -e 's/\r$//' "$@"
diff --git a/applets_sh/tac b/applets_sh/tac
new file mode 100755 (executable)
index 0000000..c5a8e39
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# TODO: use getopt to avoid parsing options as filenames,
+# and to support -- and --help
+for i in "$@"
+do
+sed -e '1!G;h;$!d' "$i"
+done
diff --git a/applets_sh/unix2dos b/applets_sh/unix2dos
new file mode 100755 (executable)
index 0000000..70e0429
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# TODO: use getopt to avoid parsing options as filenames,
+# and to support -- and --help
+[ $# -ne 0 ] && DASH_I=-i
+sed $DASH_I -e 's/$/\r/' "$@"