LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-03-2023, 03:21 PM   #1
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 371

Rep: Reputation: 172Reputation: 172
patch to 15.0 /etc/profile and /etc/profile.d for Bourne errors during login


/etc/profile "contains system-wide defaults used by all Bourne (and related) shells".

This is mostly true. Most of /etc/profile and its children in /etc/profile.d is strictly compliant to Bourne. A few non-Bourne idioms have crept in. The patches below prevent Bourne shell from throwing errors during login.

Code:
--- /etc/profile.orig   2021-08-30 18:05:00.000000000 +0000
+++ /etc/profile        2023-01-03 20:28:31.530389919 +0000
@@ -2,9 +2,9 @@
 # all Bourne (and related) shells.
 
 # Set the values for some environment variables:
-export MINICOM="-c on"
-export HOSTNAME="`cat /etc/HOSTNAME`"
-export LESSOPEN="|lesspipe.sh %s"
+export MINICOM ; MINICOM="-c on"
+export HOSTNAME ; HOSTNAME="`cat /etc/HOSTNAME`"
+export LESSOPEN ; LESSOPEN="|lesspipe.sh %s"
 # Setting a default $LESS was something inherited from SLS many years ago,
 # but apparently the previous setting of "-M" causes display issues with
 # some programs (i.e. git log). Adding "-R" as well fixes this, but some
@@ -12,11 +12,11 @@
 # actually "-r" that's the dangerous one). Anyway, it might be best to just
 # leave this unset by default. Uncomment it if you like, or set up your
 # own definition or aliases on a per-account basis.
-#export LESS="-M -R"
+#export LESS ; LESS="-M -R"
 
 # If the user doesn't have a .inputrc, use the one in /etc.
 if [ ! -r "$HOME/.inputrc" ]; then
-  export INPUTRC=/etc/inputrc
+  export INPUTRC ; INPUTRC=/etc/inputrc
 fi
 
 # Set the default system $PATH:
@@ -59,7 +59,7 @@
  PS1='%n@%m:%~%# '
 elif [ "$SHELL" = "/bin/ash" ]; then
  PS1='$ '
-else
+elif [ "$SHELL" = "/bin/bash" ]; then
  PS1='\u@\h:\w\$ '
 fi
 PS2='> '
Code:
--- /etc/profile.d/coreutils-dircolors.sh.orig  2021-09-27 17:59:53.000000000 +0000
+++ /etc/profile.d/coreutils-dircolors.sh       2023-01-03 20:44:15.796769438 +0000
@@ -29,7 +29,13 @@
   # when it encounters whitespace.  The '=' flag will fix this.
   # see zshexpn(1) man-page regarding SH_WORD_SPLIT.
   alias ls='/bin/ls ${=LS_OPTIONS}'
-else
+elif [ "$SHELL" = "/bin/bash" ] ; then
+  alias ls='/bin/ls $LS_OPTIONS'
+elif [ "$SHELL" = "/bin/pdksh" ] ; then
+  alias ls='/bin/ls $LS_OPTIONS'
+elif [ "$SHELL" = "/bin/ksh" ] ; then
+  alias ls='/bin/ls $LS_OPTIONS'
+elif [ "$SHELL" = "/bin/ash" ] ; then
   alias ls='/bin/ls $LS_OPTIONS'
 fi
Code:
--- /etc/profile.d/lang.sh.orig 2022-03-14 14:47:01.722115263 +0000
+++ /etc/profile.d/lang.sh      2023-01-03 20:47:08.156749226 +0000
@@ -3,14 +3,17 @@
 # For a list of locales which are supported by this machine, type:
 #   locale -a
 
+export LANG
+export LC_COLLATE
+
 # en_US is the Slackware default locale:
-#export LANG=en_US
+#LANG=en_US
 
 # 'C' is the old Slackware (and UNIX) default, which is 127-bit
 # ASCII with a charmap setting of ANSI_X3.4-1968.  These days,
 # it's better to use en_US or another modern $LANG setting to
 # support extended character sets.
-#export LANG=C
+#LANG=C
 
 # There is also support for UTF-8 locales, but be aware that
 # some programs may possibly misbehave under UTF-8.  In those
@@ -23,10 +26,10 @@
 #
 # UTF-8 locales will include "UTF-8" in the output.
 #
-export LANG=en_US.UTF-8
+LANG=en_US.UTF-8
 
 # Another option for en_US:
-#export LANG=en_US.ISO8859-1
+#LANG=en_US.ISO8859-1
 
 # One side effect of the newer locales is that the sort order
 # is no longer according to ASCII values, so the sort order will
@@ -34,7 +37,7 @@
 # can break scripts, we'll stick with traditional ASCII sorting.
 # If you'd prefer the sort algorithm that goes with your $LANG
 # setting, comment this out.
-export LC_COLLATE=C
+LC_COLLATE=C
 
 # End of /etc/profile.d/lang.sh
Code:
--- /etc/profile.d/libglib2.sh.orig     2021-09-01 17:51:06.000000000 +0000
+++ /etc/profile.d/libglib2.sh  2023-01-03 20:48:36.914253884 +0000
@@ -16,10 +16,10 @@
 
 # Determine if the locale is UTF-8:
 if locale charmap 2> /dev/null | grep -q UTF-8 ; then
-  export G_FILENAME_ENCODING="@locale"
+  export G_FILENAME_ENCODING ; G_FILENAME_ENCODING="@locale"
 fi
 
 # It doesn't hurt to export this since G_FILENAME_ENCODING takes priority
 # over G_BROKEN_FILENAMES:
-export G_BROKEN_FILENAMES=1
+export G_BROKEN_FILENAMES ; G_BROKEN_FILENAMES=1
Code:
--- /etc/profile.d/vdpau.sh.orig        2015-03-14 21:20:20.000000000 +0000
+++ /etc/profile.d/vdpau.sh     2023-01-03 20:51:04.886095376 +0000
@@ -1,22 +1,24 @@
 #!/bin/sh
 
 # Disable debugging output of the vdpau backend
-export VDPAU_LOG=0
+export VDPAU_LOG ; VDPAU_LOG=0
+
+export VDPAU_DRIVER
 
 # Use the vdpau backend of the nvidia binary driver
-#export VDPAU_DRIVER="nvidia"
+#VDPAU_DRIVER="nvidia"
 
 # Use the vdpau backend of the nouveau driver
-#export VDPAU_DRIVER="nouveau"
+#VDPAU_DRIVER="nouveau"
 
 # Use the vdpau backend of the r300 driver
-#export VDPAU_DRIVER="r300"
+#VDPAU_DRIVER="r300"
 
 # Use the vdpau backend of the r600 driver
-#export VDPAU_DRIVER="r600"
+#VDPAU_DRIVER="r600"
 
 # Use the vdpau backend of the radeonsi driver
-#export VDPAU_DRIVER="radeonsi"
+#VDPAU_DRIVER="radeonsi"
 
 # Use the va-api/opengl backend
-#export VDPAU_DRIVER="va_gl"
+#VDPAU_DRIVER="va_gl"
 
Old 01-05-2023, 05:52 AM   #2
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,550

Rep: Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405Reputation: 3405
Excuse me, BUT you tested those patches?

True, you found some bashismes, BUT from what I know - and I use Linux since really long time (and not necessarily Slackware), the variables export fully compatible with the Bourne Shell should be something like this
Code:
VDPAU_LOG=0

export VDPAU_LOG
Please note that the variable is exported after it's set.

On contrary, you do something like this
Code:
export VDPAU_LOG ; VDPAU_LOG=0
I do not think this is correct.

Even IF this works (which I sincerely doubt), God knows what shell you use if it accepts this....

Last edited by LuckyCyborg; 01-05-2023 at 05:56 AM.
 
1 members found this post helpful.
Old 01-05-2023, 06:27 AM   #3
commandlinegamer
Member
 
Registered: Dec 2007
Posts: 163

Rep: Reputation: 51
It does work, insofar as I've tested: setting a variable after the export command, invoking another shell, and checking the value of the variable.

But setting the variable first has long been the standard way of doing things, if my copy of The UNIX System (Bourne, 1983) is to be believed.
 
Old 01-05-2023, 07:34 AM   #4
pghvlaans
Member
 
Registered: Jan 2021
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 459

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
I'm a little curious about the coreutils-dircolors.sh patch.

I know the list of shells in the "elif" statements comes from /etc/profile, but it seems a bit counter-intuitive to leave other shells without an ls alias (particularly dash, which, although a counter-intuitive choice for an interactive shell, comes with a full installation of Slackware; /bin/ash is now a symlink to /bin/dash anyway). pdksh was the original Slackware *ksh, but it doesn't seem to have been provided for over twenty years.
 
Old 01-05-2023, 01:49 PM   #5
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,533

Rep: Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515Reputation: 8515
I looked all the way back to SLS to see if I could blame that false statement on somebody else. ;-) It still doesn't strike me as something I'd write, but who knows -- it's old in any case.

This is probably the only patch that's needed:

Code:
--- /etc/profile.orig   2021-08-30 13:05:00.000000000 -0500
+++ /etc/profile        2023-01-05 13:50:32.436240429 -0600
@@ -1,5 +1,6 @@
 # /etc/profile: This file contains system-wide defaults used by
-# all Bourne (and related) shells.
+# the GNU Bourne-Again SHell (/bin/bash) and others that are
+# sufficiently compatible.
 
 # Set the values for some environment variables:
 export MINICOM="-c on"
 
3 members found this post helpful.
Old 01-05-2023, 01:55 PM   #6
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Pat --

You forgot your smiley

-- kjh
 
1 members found this post helpful.
  


Reply

Tags
15.0, bourne, patches, profile, profile.d



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Login shell with zsh errors after executing /etc/profile iluvatar1 Slackware 3 01-03-2022 10:14 PM
STRETCH,mate: Why neither: /etc/profile nor /etc/environment is parsed for gui login? ardabro Debian 4 10-07-2015 11:52 PM
Catching mysql errors in bourne shell Geneset Linux - General 1 04-05-2009 02:08 PM
Errors, Errors, and more Errors (KDE 3.4.x GUI Errors) Dralnu Linux - Software 2 05-13-2006 08:30 AM
bourne shell /etc/passwd /etc/shadow uribo Programming 2 05-09-2003 11:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration