make setenv set -u safe and fix behaviour for no args

This commit is contained in:
tg 2015-07-18 23:03:24 +00:00
parent 0df20b04b8
commit c2d9863a05

View File

@ -1,9 +1,9 @@
# $Id$ # $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.100 2015/07/10 19:36:33 tg Exp $ # $MirOS: src/bin/mksh/dot.mkshrc,v 1.101 2015/07/18 23:03:24 tg Exp $
#- #-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015 # 2011, 2012, 2013, 2014, 2015
# Thorsten Glaser <tg@mirbsd.org> # mirabilos <tg@mirbsd.org>
# #
# Provided that these terms and disclaimer and all copyright notices # Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission # are retained or reproduced in an accompanying document, permission
@ -384,7 +384,11 @@ function Lstripcom {
# give MidnightBSD's laffer1 a bit of csh feeling # give MidnightBSD's laffer1 a bit of csh feeling
function setenv { function setenv {
\eval "'export' \"$1\""'="$2"' if (( $# )); then
\eval '\export "$1"="${2:-}"'
else
\typeset -x
fi
} }
# toggle built-in aliases and utilities, and aliases and functions from mkshrc # toggle built-in aliases and utilities, and aliases and functions from mkshrc