run something with a cleaned up *envp
authorThorsten Glaser <tg@mirbsd.org>
Wed, 9 Mar 2011 14:37:55 +0000 (15:37 +0100)
committerThorsten Glaser <tg@mirbsd.org>
Wed, 9 Mar 2011 14:37:55 +0000 (15:37 +0100)
posix/cleanenv [new file with mode: 0644]

diff --git a/posix/cleanenv b/posix/cleanenv
new file mode 100644 (file)
index 0000000..e9be30d
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $MirOS: src/scripts/cleanenv,v 1.4 2009/03/29 13:04:20 tg Exp $
+#-
+# Not complicated enough for copyright.
+
+p=/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin
+
+if test x"$1" = x"-"; then
+       shift
+       exec /usr/bin/env -i \
+           PATH=$p TZ=UTC HOME=/ \
+           "$@"
+fi
+exec /usr/bin/env -i \
+    PATH=$p TZ=UTC $(locale 2>/dev/null | fgrep LC_CTYPE) \
+    DISPLAY="$DISPLAY" HOME="${HOME:-/}" TERM="${TERM:-vt100}" USER="${USER}" \
+    "$@"