diff --git a/Makefile b/Makefile
index f88859bc..af15a0b4 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ games \
mbr \
mkinitrd \
regress \
+sh \
tix \
utils \
kernel
diff --git a/doc/user-guide b/doc/user-guide
index f9247f7b..037c9bbf 100644
--- a/doc/user-guide
+++ b/doc/user-guide
@@ -182,7 +182,7 @@ Sortix comes with a number of home-made programs. Here is an overview:
* `regress` - run system tests
* `rm` - remove file
* `rmdir` - remove empty directory
-* `sh` - alias for the shell
+* `sh` - command shell
* `sleep` - delay for a specified amount of time
* `sort` - sort lines of text files
* `tail` - display end of file
@@ -494,6 +494,12 @@ driver program.
This program converts a binary file to an C array.
+### sh ###
+
+This is the Sortix shell. Currently the `sh` program is a wrapper that looks for
+a better non-interactive shell if running a script, otherwise it invokes the
+hacky `sortix-sh` program.
+
### Sortix Kernel ###
The Sortix kernel is the core of the Sortix operating system. It provides all
diff --git a/sh/.gitignore b/sh/.gitignore
new file mode 100644
index 00000000..5d2efd96
--- /dev/null
+++ b/sh/.gitignore
@@ -0,0 +1,2 @@
+sh
+sortix-sh
diff --git a/sh/Makefile b/sh/Makefile
new file mode 100644
index 00000000..b327b0e1
--- /dev/null
+++ b/sh/Makefile
@@ -0,0 +1,30 @@
+SOFTWARE_MEANT_FOR_SORTIX=1
+include ../build-aux/platform.mak
+include ../build-aux/compiler.mak
+include ../build-aux/version.mak
+include ../build-aux/dirs.mak
+
+OPTLEVEL?=$(DEFAULT_OPTLEVEL)
+CXXFLAGS?=$(OPTLEVEL)
+
+CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
+CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
+
+BINARIES:=sh sortix-sh
+
+all: $(BINARIES)
+
+.PHONY: all install clean
+
+install: all
+ mkdir -p $(DESTDIR)$(BINDIR)
+ install $(BINARIES) $(DESTDIR)$(BINDIR)
+
+sortix-sh: sh.cpp
+ $(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+sh: proper-sh.cpp
+ $(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+clean:
+ rm -f $(BINARIES) *.o
diff --git a/utils/sh.cpp b/sh/proper-sh.cpp
similarity index 99%
rename from utils/sh.cpp
rename to sh/proper-sh.cpp
index 5df3aea2..41fb5e59 100644
--- a/utils/sh.cpp
+++ b/sh/proper-sh.cpp
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with
this program. If not, see .
- sh.cpp
+ proper-sh.cpp
Forward execution to the best shell.
*******************************************************************************/
diff --git a/utils/sortix-sh.cpp b/sh/sh.cpp
similarity index 99%
rename from utils/sortix-sh.cpp
rename to sh/sh.cpp
index 138de3ea..b95b3aba 100644
--- a/utils/sortix-sh.cpp
+++ b/sh/sh.cpp
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with
this program. If not, see .
- sortix-sh.cpp
+ sh.cpp
A hacky Sortix shell.
*******************************************************************************/
diff --git a/utils/.gitignore b/utils/.gitignore
index 314a0aa9..2c1719d7 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -32,10 +32,8 @@ pager
pwd
rm
rmdir
-sh
sleep
sort
-sortix-sh
tail
time
tr
diff --git a/utils/Makefile b/utils/Makefile
index 4deec737..0e88bd63 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -44,10 +44,8 @@ pager \
pwd \
rm \
rmdir \
-sh \
sleep \
sort \
-sortix-sh \
tail \
time \
tr \