From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19512 invoked by alias); 11 Dec 2016 18:07:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40157 Received: (qmail 22519 invoked from network); 11 Dec 2016 18:07:10 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-2.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.66):SA:0(-0.0/5.0):. Processed in 5.398457 secs); 11 Dec 2016 18:07:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.66 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=Ya9AnFlf c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=NLZqzBF-AAAA:8 a=EBhLCYyc0ni80nlrOXIA:9 a=QEXdDO2ut3YA:10 a=wW_WBVUImv98JQXhvVPZ:22 Date: Sun, 11 Dec 2016 18:06:55 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: off topic Message-ID: <20161211180655.616c1ea0@ntlworld.com> In-Reply-To: <20161209192406.GA27532@fujitsu.shahaf.local2> References: <20161209122958.GD19559@256bit.org> <57127.1481294647@hydra.kiddle.eu> <584AC8AC.9050406@eastlink.ca> <62522.1481300922@hydra.kiddle.eu> <584AEDBF.2050402__19991.0537027337$1481307418$gmane$org@eastlink.ca> <20161209192406.GA27532@fujitsu.shahaf.local2> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 9 Dec 2016 19:24:06 +0000 Daniel Shahaf wrote: > % env -i ZDOTDIR=3D$(mktemp -d) zsh > This is the Z Shell configuration function for new users, > zsh-newuser-install. > =E2=8B=AE > (2) Populate your /tmp/tmp.Z4bUNG8Gz5/.zshrc with the configuration = recommended > by the system administrator and exit (you will need to edit > the file by hand, if so desired). > =20 > --- Type one of the keys in parentheses ---=20 >=20 > Typing "2" creates a .zshrc with reasonable default settings, and drops > the user to the prompt; no further menu choices. The catch is that that > check is hardcoded to inspect /etc/zsh/newuser.zshrc.recommended; that > is, it ignores configure's --prefix. >=20 > So if we could make that check honour @PREFIX@, and ship a "recommended > zshrc" that is less minimal than the default no-zshrc behaviour... > I think that'd be a good step forward. At the time there was a reason why newuser stuff used a fixed path rather than tracking every version of the package, but not necessarily a good one --- since the vast majority of users now will be receiving things via a distribution it doesn't really apply. My experience with recommended settings in previous threads (the last one petered out some time ago now) is much like Gladstone's with the Irish Question --- every time you think you're getting close, they change the question(*). But if you or anyone wants to pursue this further, which I will happily support in the distribution, you might want something like the following (untested --- and in particular untested with out-of-tree configure which might make a difference). pws (*) You'll need to add "1066 and all that" to the search for [de?]mystification on the subject. commit 463a58ded82d3371b969bf9ee1b04814464d91bd Author: Peter Stephenson Date: Fri Dec 9 21:24:37 2016 +0000 Make recommended zshrc location configurable. diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-= newuser-install index e4028fd..f639b6f 100644 --- a/Functions/Newuser/zsh-newuser-install +++ b/Functions/Newuser/zsh-newuser-install @@ -9,11 +9,29 @@ setopt extendedglob nonomatch warncreateglobal =20 # How the function will be referred to. local myname=3Dzsh-newuser-install +integer force + +if [[ $1 =3D -f ]]; then + (( force =3D 1 )) + shift +fi +if [[ $1 =3D - || $1 =3D=3D -- ]]; then + shift +fi +local zshrc_rec=3D/etc/zsh/newuser.zshrc.recommended +if [[ -n $1 ]]; then + if [[ $1 =3D /* ]]; then + zshrc_rec=3D$1 + else + print "Usage: $0 [ -f ] [ /path/to/newuser.zshrc.recommened ]" >&2 + return 1 + fi +fi =20 # Quick test not requiring any setting up. # Don't run if we're root. (These variables are provided by the shell.) if (( EUID =3D=3D 0 || UID =3D=3D 0 )); then - if [[ $1 =3D -f ]]; then + if (( force )); then print -r "$myname: won't run as root. Read the manual." >&2 fi return 1 @@ -96,7 +114,7 @@ fi # if this really is a new user this probably isn't the right # time for screeds of explanation. if [[ ! -w $zd ]]; then - if [[ $1 =3D -f ]]; then + if (( force )); then print -r "$myname: can't write to $zdmsg." >&2 fi return 1 @@ -104,7 +122,7 @@ fi =20 # Don't run unless we can talk to the user. if [[ ! -t 0 || ! -t 1 ]]; then - if [[ $1 =3D -f ]]; then + if (( force )); then print -r "$myname: can only be used interactively." >&2 fi return 1 @@ -115,7 +133,7 @@ if (( ${LINES:-0} < 15 || ${COLUMNS:-0} < 72 )); then return 1 fi =20 -if [[ $1 !=3D -f ]]; then +if (( ! force )); then # The zsh/newuser module already tests for the following, so this test o= nly # triggers if zsh-newuser-install is run by hand. if [[ -e $zd/.zshenv || -e $zd/.zprofile || \ @@ -934,7 +952,7 @@ fi =20 =20 # skip initial screen if the function was deliberately run by the user. -if [[ $1 !=3D -f ]]; then +if (( ! force )); then clear print -r "This is the Z Shell configuration function for new users, $myname. @@ -954,7 +972,7 @@ You can: print -r " (1) Continue to the main menu. " - if [[ -f /etc/zsh/newuser.zshrc.recommended ]]; then + if [[ -f $zshrc_rec ]]; then print -r "(2) Populate your $zdmsg/.zshrc with the configuration reco= mmended by the system administrator and exit (you will need to edit the file by hand, if so desired). @@ -978,14 +996,14 @@ You can: ;; =20 (2) - cp /etc/zsh/newuser.zshrc.recommended $zd/.zshrc + cp $zshrc_rec $zd/.zshrc source $zd/.zshrc return 0 ;; =20 (*) print -r "Aborting." - if [[ $1 !=3D -f ]]; then + if (( ! force )); then print "\ The function will be run again next time. To prevent this, execute: touch $zdmsg/.zshrc" @@ -1036,7 +1054,7 @@ ${install_state[options]:+ ($install_state[options].= )} (a) Abort all settings and start from scratch. Note this will overwrite any settings from $myname already in the startup file. It will not alter any of your other settings, however." - if [[ $1 =3D -f ]]; then + if (( force )); then print -r " (q) Quit and do nothing else." else @@ -1078,7 +1096,7 @@ ${install_state[options]:+ ($install_state[options].= )} elif [[ ! -f $zd/.zshrc ]]; then print -r $msg >$zd/.zshrc fi - if [[ $1 !=3D -f ]]; then + if (( force )); then print -r "The function will not be run in future, but you can run it yourself as follows: autoload -Uz $myname diff --git a/Scripts/.gitignore b/Scripts/.gitignore new file mode 100644 index 0000000..c889ba7 --- /dev/null +++ b/Scripts/.gitignore @@ -0,0 +1 @@ +newuser diff --git a/Scripts/newuser b/Scripts/newuser deleted file mode 100644 index b5d7421..0000000 --- a/Scripts/newuser +++ /dev/null @@ -1,8 +0,0 @@ -# zsh script sourced at startup when a user is found to have -# no startup files. See the documentation for the zsh/newuser -# module in zshmodules(1). - -if functions zsh-newuser-install >/dev/null 2>&1 || - autoload -U +X zsh-newuser-install; then - zsh-newuser-install -fi diff --git a/Scripts/newuser.in b/Scripts/newuser.in new file mode 100644 index 0000000..678d115 --- /dev/null +++ b/Scripts/newuser.in @@ -0,0 +1,13 @@ +# zsh script sourced at startup when a user is found to have +# no startup files. See the documentation for the zsh/newuser +# module in zshmodules(1). + +zshrc_rec=3D@zshrc_rec@ +if [[ -z $zshrc_rec ]]; then + prefix=3D@prefix@ + zshrc_rec=3D@sysconfdir@/zsh/newuser.zshrc.recommended +fi +if functions zsh-newuser-install >/dev/null 2>&1 || + autoload -U +X zsh-newuser-install; then + zsh-newuser-install $zshrc_rec +fi diff --git a/configure.ac b/configure.ac index 920c2fc..55d3acd 100644 --- a/configure.ac +++ b/configure.ac @@ -237,11 +237,22 @@ if test "x$zlogout" !=3D xno; then AC_DEFINE_UNQUOTED(GLOBAL_ZLOGOUT, "$zlogout") fi =20 +AC_ARG_ENABLE(zshrc-rec, +AC_HELP_STRING([-enable-zshrc-rec=3DFILE], [the full pathname of a recomme= nded zshrc file for new users]), +[zshrc_rec=3D"$enableval"], +[if test "x$etcdir" =3D xno; then + zshrc_rec=3Dno +else + zshrc_rec=3D"$etcdir/zsh/newuser.zshrc.recommended" +fi]) +dnl zshrc_rec is only used by a script and is not needed in the source. + AC_SUBST(zshenv)dnl AC_SUBST(zshrc)dnl AC_SUBST(zprofile)dnl AC_SUBST(zlogin)dnl AC_SUBST(zlogout)dnl +AC_SUBST(zshrc_rec)dnl =20 dnl Do you want dynamically loaded binary modules. ifdef([dynamic],[undefine([dynamic])])dnl @@ -3283,7 +3294,7 @@ AC_SUBST_FILE(DEFS_MK)dnl AC_SUBST_FILE(VERSION_MK)dnl =20 AC_CONFIG_FILES(Config/defs.mk Makefile Doc/Makefile Etc/Makefile \ -Src/Makefile Test/Makefile) +Src/Makefile Test/Makefile Scripts/newuser) AC_CONFIG_COMMANDS([config.modules], [. ./config.modules.sh]) AC_CONFIG_COMMANDS([stamp-h], [echo >stamp-h]) =20