Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Want to replace bash w zsh as system shell on Ubuntu



Joke de Buhr wrote:
> On Tuesday 02 February 2010 13:37:27 Frank Terbeck wrote:
>> But $(...) is perfectly correct syntax in POSIX shells. You may be
>> confused here, because older bourne shells don't support this. Shells
>> that adhere the standard, however, do.
>
> You're right. I thing the $(<file) cat-replacement was not transfered to posix 
> shells.

Yes, $(<file) is a special form of $(cat file), which a lot of shells
implement. POSIX doesn't say anything about it, if I'm not mistaken.

In zsh, $(<file) doesn't look at $READNULLCMD, which it does if you just
use `<file' at the command line.

>> Yeah, it's also funny to suddenly end up with a number of your files
>> being owned by root (shouldn't happen with zsh's history file, since zsh
>> keeps track of the file's permissions even with the HIST_SAVE_BY_COPY
>> option enabled - which is the default; but not everything is as cautious
>> as zsh is).
>
> You're right. That's pretty inconvenient using sudo but sudo is the only way 
> to work with multiple administrators while each admin keeps it's own set of 
> configuration files. On a single person system this doesn't matter.

I'd argue, that if the admins really really need their tailored to fit
customised setups while working as root, they spend way too much time as
root. :-)

> You can always use an exit hook to clean your home directory after using sudo. 
> Add something like this to your ~/.zshrc file. Upon exiting a sudo root 
> sessions zsh changes the permissions of all files underneath $HOME which now 
> don't have the UID or GID before running sudo and now have a UID or GID of the 
> user you switched to (sudo -u postgres):

Yes, you could.  But such things are hard to get right. The code below
may change ownership of files you may have set to something else
deliberately. Also, if your $HOME is rather big, that's an expensive
operation, I'd rather not take.

I still think it's less pain not going down that road. And of course
everybody who disagrees may do that. :-)

> correct_permissions() {
>   emulate -R zsh

I think I'd use -L instead of -R, although in `zshexit' it probably
doesn't make much of a difference.

>   setopt extendedglob

I think adding `nullbglob' here would make sense, too, so the glob below
doesn't error out if it doesn't match anything.

>   trap '' HUP INT QUIT TERM
>
>   if [[ -n $SUDO_UID && -n $SUDO_GID ]] {
>     print 'Correcting file permissions. This may take a while.'
>
>     matches=("$HOME"/((.*|*)/)#*(#q^u${SUDO_UID}u${UID},^g${SUDO_GID}g${GID}))
>     [[ -n ${matches} ]] && chown $SUDO_UID:$SUDO_GID "${matches[@]}"

(( ${#matches} > 0 )) && ...

>   }
> }
>
> zshexit_functions+=(correct_permissions)

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



Messages sorted by: Reverse Date, Date, Thread, Author