Re: [33591] branches/release_1_6/base/portmgr/dmg/postflight
On Jan 31, 2008, at 00:36, jmpp@macports.org wrote:
Revision: 33591 http://trac.macosforge.org/projects/macports/changeset/33591 Author: jmpp@macports.org Date: 2008-01-30 22:36:50 -0800 (Wed, 30 Jan 2008)
Log Message: -----------
Seems like the source of all my pains is Installer.app, which aparently limits the environment I run under in some way and forces SHELL to /bin/sh always (even if I run as a login shell, it just doesn't seem to be possible to get to the user's info), rendering useless the `case` routine that tries to determine the shell I need to tweak.
As a lame workaround, I'm going to glob for *sh to match /bin/sh and thus still write my settings to the common profile file, leaving all those *csh users out there a bit in dispair.
Could you read the user's real shell like this? USHELL="$(nicl . -read /users/rschmidt shell | sed 's/^shell: //'')"
On Jan 31, 2008, at 3:36 AM, Ryan Schmidt wrote:
On Jan 31, 2008, at 00:36, jmpp@macports.org wrote:
Revision: 33591 http://trac.macosforge.org/projects/macports/changeset/33591 Author: jmpp@macports.org Date: 2008-01-30 22:36:50 -0800 (Wed, 30 Jan 2008)
Log Message: -----------
Seems like the source of all my pains is Installer.app, which aparently limits the environment I run under in some way and forces SHELL to /bin/sh always (even if I run as a login shell, it just doesn't seem to be possible to get to the user's info), rendering useless the `case` routine that tries to determine the shell I need to tweak.
As a lame workaround, I'm going to glob for *sh to match /bin/sh and thus still write my settings to the common profile file, leaving all those *csh users out there a bit in dispair.
Could you read the user's real shell like this?
USHELL="$(nicl . -read /users/rschmidt shell | sed 's/^shell: //'')"
Very nice suggestion Ryan, thanks! I'd been making assumptions about the environment under which a shell script runs, and not only do I think I was mistaken in the general case, but also Installer.app seems to make the situation even worse by apparently enforcing a very specific environment (understandable from the security concerned point of view), but then again it could have been just my tired eyes last night reading that from /var/log/install.log In any case, your suggestion seems straight forward and simple enough, so I'll quit trying to reinvent the wheel and will give it a shot as soon as I get a few spare minutes (there are some implementation details, like nicl for < 10.4 and dscl for Leopard, among others). Regards,... -jmpp
On Jan 31, 2008, at 10:29 AM, Juan Manuel Palacios wrote:
USHELL="$(nicl . -read /users/rschmidt shell | sed 's/^shell: //'')"
In any case, your suggestion seems straight forward and simple enough, so I'll quit trying to reinvent the wheel and will give it a shot as soon as I get a few spare minutes (there are some implementation details, like nicl for < 10.4 and dscl for Leopard, among others).
except that you want to use dscl instead of nicl (and then need to tweak the sed pattern). Something like: dscl . -read /users/dluke shell | sed 's/^.*shell: //' -- Daniel J. Luke +========================================================+ | *---------------- dluke@geeklair.net ----------------* | | *-------------- http://www.geeklair.net -------------* | +========================================================+ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | +========================================================+
On Jan 31, 2008, at 10:08, Daniel J. Luke wrote:
On Jan 31, 2008, at 10:29 AM, Juan Manuel Palacios wrote:
USHELL="$(nicl . -read /users/rschmidt shell | sed 's/^shell: //'')"
In any case, your suggestion seems straight forward and simple enough, so I'll quit trying to reinvent the wheel and will give it a shot as soon as I get a few spare minutes (there are some implementation details, like nicl for < 10.4 and dscl for Leopard, among others).
except that you want to use dscl instead of nicl (and then need to tweak the sed pattern).
Something like:
dscl . -read /users/dluke shell | sed 's/^.*shell: //'
For those without access to both 10.4 and 10.5 machines: On 10.4: nicl . -read /users/$USER shell and dscl . -read /users/$USER shell both produce output like this: shell: /bin/bash On 10.5, nicl does not exist, and dscl . -read /users/$USER shell produces output like this: dsAttrTypeNative:shell: /bin/bash So we should set THE_UTIL to "nicl" on 10.4 and earlier, or "dscl" on 10.5 and up, and then use: $THE_UTIL . -read /users/$USER shell | sed 's/^.*: //'
On Jan 31, 2008, at 11:25 AM, Ryan Schmidt wrote:
So we should set THE_UTIL to "nicl" on 10.4 and earlier, or "dscl" on 10.5 and up, and then use:
$THE_UTIL . -read /users/$USER shell | sed 's/^.*: //'
I don't see why you need to use nicl anywhere (if they both produce the same output as you say). As an added bonus, dscl will work on 10.4 even if the user's information isn't stored in netinfo (whereas nicl won't). -- Daniel J. Luke +========================================================+ | *---------------- dluke@geeklair.net ----------------* | | *-------------- http://www.geeklair.net -------------* | +========================================================+ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | +========================================================+
On Jan 31, 2008, at 10:53, Daniel J. Luke wrote:
On Jan 31, 2008, at 11:25 AM, Ryan Schmidt wrote:
So we should set THE_UTIL to "nicl" on 10.4 and earlier, or "dscl" on 10.5 and up, and then use:
$THE_UTIL . -read /users/$USER shell | sed 's/^.*: //'
I don't see why you need to use nicl anywhere (if they both produce the same output as you say).
As an added bonus, dscl will work on 10.4 even if the user's information isn't stored in netinfo (whereas nicl won't).
Does dscl exist and work on 10.3 and earlier too? The manpage for nicl is from December 2000 which makes me think it exists back to the beginning of Mac OS X, whereas the manpage for dscl is from August 2003. 10.3 was released in October 2003 so maybe it does contain dscl. Can someone with 10.3 (Chris?) please test whether dscl . -read /users/$USER shell works on 10.3, and if so what its output is?
On Jan 31, 2008, at 12:04 PM, Ryan Schmidt wrote:
As an added bonus, dscl will work on 10.4 even if the user's information isn't stored in netinfo (whereas nicl won't).
Does dscl exist and work on 10.3 and earlier too?
I'm not certain (I think so, given 2 below), but there are two points I would make here. 1. Officially we support the current and previous release of Mac OS X, so 10.3 isn't really a target anymore (and having the automatic path setup not work on 10.3 isn't enough to block usage there - people can still set up $PATH manually like they had to with older releases). 2. MacPorts base already uses dscl (see portutil.tcl) -- Daniel J. Luke +========================================================+ | *---------------- dluke@geeklair.net ----------------* | | *-------------- http://www.geeklair.net -------------* | +========================================================+ | Opinions expressed are mine and do not necessarily | | reflect the opinions of my employer. | +========================================================+
On Jan 31, 2008, at 11:35, Daniel J. Luke wrote:
On Jan 31, 2008, at 12:04 PM, Ryan Schmidt wrote:
As an added bonus, dscl will work on 10.4 even if the user's information isn't stored in netinfo (whereas nicl won't).
Does dscl exist and work on 10.3 and earlier too?
I'm not certain (I think so, given 2 below), but there are two points I would make here.
1. Officially we support the current and previous release of Mac OS X, so 10.3 isn't really a target anymore (and having the automatic path setup not work on 10.3 isn't enough to block usage there - people can still set up $PATH manually like they had to with older releases).
2. MacPorts base already uses dscl (see portutil.tcl)
Chris tested on 10.3 and it works: On Jan 31, 2008, at 11:06, Chris Janton wrote:
face@x:face:122 $ sw_vers ProductName: Mac OS X Server ProductVersion: 10.3.9 BuildVersion: 7W98 face@x:face:123 $ dscl . -read /users/$USER shell shell: /bin/bash face@x:face:124 $ which dscl /usr/bin/dscl face@x:face:125 $
If we can support 10.3 without too much additional effort, we should. In this case, we can use dscl on 10.3, 10.4 and 10.5 so no additional effort is required.
Daniel J. Luke wrote:
1. Officially we support the current and previous release of Mac OS X, so 10.3 isn't really a target anymore (and having the automatic path setup not work on 10.3 isn't enough to block usage there - people can still set up $PATH manually like they had to with older releases).
Mac OS X 10.5 isn't really out of the Public Beta stage until 10.5.2 and a new X11.app arrives, so it probably doesn't hurt to support Mac OS X 10.3 a little longer still... Besides, PATH isn't working on Leopard either but that doesn't seem to stop everyone (just the occasional puzzled newcomer) Some of us would even *prefer* it being "manual". --anders
participants (4)
-
Anders F Björklund
-
Daniel J. Luke
-
Juan Manuel Palacios
-
Ryan Schmidt