Hi Terry, Thank you for the detailed report, it helps me to figure it out where was the issue plus the help of the service "https://codesearch.debian.net".
As you correctly said, when the "su -" is executed, the scripts located in the directory /etc/profile.d/ are executed too because it creates a login shell. The process is detailed at the end of the file "/etc/profile" and is the same for all Bourne-compatible shells, but some of them have a slighly different behaviour: if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset i fi A lot of packages use the form "su -s /bin/bash" instead of "su -". I think too that this is a better approach, the loging shell is not needed, I was wrong. The issue also affects to the init.d script, which was with the same "su -" format. I just update the repo, in dev branch, it will be available in Debian in a few weeks. https://github.com/rfrail3/tuptime.git Thanks, El 2017-12-24 05:29, Terry Roy escribió: > I had some comments from the other bug reports I file which led me to do some > more testing. Here's what I found. > > I've had three packages with this issue - spamassassin, sa-compile and > tuptime. > > The user for spamassassin and sa-compile is debian-spamd whose shell is set > to /bin/sh. The user for tuptime is tuptime whose shell is also set to > /bin/sh. No other users on my system use /bin/sh. > > Changing the shell to /bin/bash for tuptime for example, eliminates the error > with using 'su -'. > > Aliases present no problem. Functions, depending on how they are written, do. > > function somefunction () {....} causes a problem. > > function somefunction {....} causes a problem. > > somefunction () {....} does not. Using the reserved word 'function' causes > /bin/sh to throw an error. > > Interestingly, when using the reserved word function, the presence of () > changes the error message. > > With the use of (): > -sh: 5: /etc/profile.d/test.sh: Syntax error: "(" unexpected (expecting "fi") > > Without the use of (): > -sh: 5: /etc/profile.d/test.sh: function: not found > > Definitely would have been much easier to spot the error had we not used (). > > So while calling a login shell caused a problem, ultimately, it's because > /bin/sh does not recognise the reserved word 'function'. I'm not sure there's > a good solution for this. It seems to be such a specific issue. Had I not > created a user with a /bin/sh shell and tried to recreate the function for > that user, I'm not sure I would have twigged that the reserved word function > was causing the problem since the error kept coming back as the ( causing the > issue. > > Thanks.