summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Newuser/.distfiles2
-rw-r--r--Functions/Newuser/zsh-install-newuser11
-rw-r--r--Functions/Newuser/zsh-newuser-install23
3 files changed, 24 insertions, 12 deletions
diff --git a/Functions/Newuser/.distfiles b/Functions/Newuser/.distfiles
index f192b27e4..9012263a2 100644
--- a/Functions/Newuser/.distfiles
+++ b/Functions/Newuser/.distfiles
@@ -1,4 +1,4 @@
 DISTFILES_SRC='
 .distfiles
-zsh-install-newuser
+zsh-newuser-install
 '
diff --git a/Functions/Newuser/zsh-install-newuser b/Functions/Newuser/zsh-install-newuser
deleted file mode 100644
index 40bba720d..000000000
--- a/Functions/Newuser/zsh-install-newuser
+++ /dev/null
@@ -1,11 +0,0 @@
-# Function to install startup files for a new user.
-# This dummy version simply creates a new .zshrc with a comment.
-# FIXME: we don't want to distribute a file that does that, it
-# would be preferable to do nothing at all.
-
-# Sanitize environment.
-emulate -L zsh
-
-echo "# Created by newuser for $ZSH_VERSION" >${ZDOTDIR:-$HOME}/.zshrc
-
-unfunction zsh-install-newuser
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
new file mode 100644
index 000000000..6c54dc509
--- /dev/null
+++ b/Functions/Newuser/zsh-newuser-install
@@ -0,0 +1,23 @@
+# Function to install startup files for a new user.
+# This dummy version simply creates a new .zshrc with a comment.
+# FIXME: we don't want to distribute a file that does that, it
+# would be preferable to do nothing at all.
+
+# Sanitize environment.
+emulate -L zsh
+
+local zd=${ZDOTDIR:-$HOME}
+
+# The zsh/newuser module already tests for the following, so this test only
+# triggers if zsh-newuser-install is run by hand.
+#
+# In future we may want to use this mechanism to update startup files.
+if [[ -e $zd/.zshenv || -e $zd/.zprofile || -e $zd/.zshrc || -e $zs/.zlogin ]]
+then
+  print "zsh-newuser-install:  startup files exist, aborting" >&2
+  return 1
+fi
+
+echo "# Created by newuser for $ZSH_VERSION" >$zd/.zshrc
+
+unfunction zsh-newuser-install