* Re: GNU emacs locks files modified with CVS [not found] <mailman.195.1071679031.868.help-gnu-emacs@gnu.org> @ 2003-12-17 16:26 ` Kevin Rodgers 2003-12-17 19:03 ` gebser 2003-12-17 16:41 ` Pepijn Kenter 2003-12-17 17:54 ` Maurizio Loreti 2 siblings, 1 reply; 13+ messages in thread From: Kevin Rodgers @ 2003-12-17 16:26 UTC (permalink / raw) gebser@speakeasy.net wrote: > Of course everyone can set up their systems however they wish, but I > use: > > export DISPLAY=$(who -lum|awk -F '(' '{print $2}'|awk -F ')' '{print $1}'):0 > > in my ~/.bashrc and have no problem logging in and/or running remotely > whatever X apps I want. I know this isn't comp.unix.shell, but that pipe can be simplified a little by passing a regex as awk's field separator: export DISPLAY=$(who -lum | awk -F'[()]' '{print $(NF-1)}'):0 -- Kevin Rodgers ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-17 16:26 ` GNU emacs locks files modified with CVS Kevin Rodgers @ 2003-12-17 19:03 ` gebser 0 siblings, 0 replies; 13+ messages in thread From: gebser @ 2003-12-17 19:03 UTC (permalink / raw) I wrote that a long time ago when my awk skills were about nil. This was the first time looking at it again in a long, long while. But thanks. ken At 09:26 (UTC-0700) on Wed, 17 Dec 2003 Kevin Rodgers said: = gebser@speakeasy.net wrote: = = > Of course everyone can set up their systems however they wish, but I = > use: = > = > export DISPLAY=$(who -lum|awk -F '(' '{print $2}'|awk -F ')' '{print $1}'):0 = > = > in my ~/.bashrc and have no problem logging in and/or running remotely = > whatever X apps I want. = = = I know this isn't comp.unix.shell, but that pipe can be simplified a little by = passing a regex as awk's field separator: = = = export DISPLAY=$(who -lum | awk -F'[()]' '{print $(NF-1)}'):0 = = ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS [not found] <mailman.195.1071679031.868.help-gnu-emacs@gnu.org> 2003-12-17 16:26 ` GNU emacs locks files modified with CVS Kevin Rodgers @ 2003-12-17 16:41 ` Pepijn Kenter 2003-12-17 17:54 ` Maurizio Loreti 2 siblings, 0 replies; 13+ messages in thread From: Pepijn Kenter @ 2003-12-17 16:41 UTC (permalink / raw) gebser@speakeasy.net wrote: > Of course everyone can set up their systems however they wish, but I > use: Of course. When saying the .bashrc isn't the proper place for setting the DISPLAY variable, I meant that at that time you can't know what value to set it to. From your (and Maurizio Loreti's) post I learned you can use the who command to find out. So thank you both. > > export DISPLAY=$(who -lum|awk -F '(' '{print $2}'|awk -F ')' '{print $1}'):0 > > in my ~/.bashrc and have no problem logging in and/or running remotely > whatever X apps I want. > > Because it would take a lot of thinking to hash out which is the correct > file to put this in, whether the DISPLAY is a resource or not, whether...<snip> Excuse my ignorance, but what do you mean by resource in this context? Pepijn. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS [not found] <mailman.195.1071679031.868.help-gnu-emacs@gnu.org> 2003-12-17 16:26 ` GNU emacs locks files modified with CVS Kevin Rodgers 2003-12-17 16:41 ` Pepijn Kenter @ 2003-12-17 17:54 ` Maurizio Loreti 2003-12-18 17:19 ` Kevin Rodgers 2 siblings, 1 reply; 13+ messages in thread From: Maurizio Loreti @ 2003-12-17 17:54 UTC (permalink / raw) gebser@speakeasy.net writes: > Because it would take a lot of thinking to hash out which is the correct > file to put this in, whether the DISPLAY is a resource or not, whether > this variable should be set for all interactive shells or just for > logins, and because I don't wish to argue any of this, I'll just say > that I disagree and believe that .bashrc *is* the proper place for > setting DISPLAY. As said at the outset, everyone can set up their > systems however they wish. You are free to do a lot of things - to shoot yourself in a foot, if you like. I dare to dissent. From 'man bash': ,----- | When bash is invoked as an interactive login shell ... it first reads | and executes commands from the file /etc/profile, if that file exists. | After reading that file, it looks for ~/.bash_profile, ~/.bash_login, | and ~/.profile, in that order, and reads and executes commands from | the first one that exists and is readable. | ... | When an interactive shell that is not a login shell is started, bash | reads and executes commands from ~/.bashrc, if that file exists. `----- Since all non-login shells (used e.g. to run commands in a subshell) inherit the environment from the common ancestor, the login shell, I think it is just a loss of time to recompute every time an environment variable that *cannot* have been changed. YMMV, of course. -- Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html Dept. of Physics, Univ. of Padova, Italy ROT13: ybergv@cq.vasa.vg ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-17 17:54 ` Maurizio Loreti @ 2003-12-18 17:19 ` Kevin Rodgers 0 siblings, 0 replies; 13+ messages in thread From: Kevin Rodgers @ 2003-12-18 17:19 UTC (permalink / raw) Maurizio Loreti wrote: > gebser@speakeasy.net writes: > > >>Because it would take a lot of thinking to hash out which is the correct >>file to put this in, whether the DISPLAY is a resource or not, whether >>this variable should be set for all interactive shells or just for >>logins, and because I don't wish to argue any of this, I'll just say >>that I disagree and believe that .bashrc *is* the proper place for >>setting DISPLAY. As said at the outset, everyone can set up their >>systems however they wish. >> > > You are free to do a lot of things - to shoot yourself in a foot, if > you like. I dare to dissent. From 'man bash': > > ,----- > | When bash is invoked as an interactive login shell ... it first reads > | and executes commands from the file /etc/profile, if that file exists. > | After reading that file, it looks for ~/.bash_profile, ~/.bash_login, > | and ~/.profile, in that order, and reads and executes commands from > | the first one that exists and is readable. > | ... > | When an interactive shell that is not a login shell is started, bash > | reads and executes commands from ~/.bashrc, if that file exists. > `----- > > Since all non-login shells (used e.g. to run commands in a subshell) > inherit the environment from the common ancestor, the login shell, I > think it is just a loss of time to recompute every time an environment > variable that *cannot* have been changed. YMMV, of course. Right. So ~/.bash_profile, ~/.bash_login, or ~/.profile is the right place to set DISPLAY. -- Kevin Rodgers ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <mailman.138.1071587578.868.help-gnu-emacs@gnu.org>]
* Re: GNU emacs locks files modified with CVS [not found] <mailman.138.1071587578.868.help-gnu-emacs@gnu.org> @ 2003-12-16 14:51 ` Pepijn Kenter 2003-12-16 16:26 ` gebser 2003-12-17 6:42 ` Maurizio Loreti 0 siblings, 2 replies; 13+ messages in thread From: Pepijn Kenter @ 2003-12-16 14:51 UTC (permalink / raw) gebser@speakeasy.net wrote: > There's two ways which will keep/set the DISPLAY variable: > > First, if the DISPLAY variable is set in user1 and you do "su user2", > then the environment of user1 will carry into user2. IOW, you're good. > > Second, if you, instead, do "su - user2", then you will have a fresh > environment, that of user2. If user2's environment doesn't have the > DISPLAY variable set properly, you can do this by setting this in > user2's ~/.bashrc file... if user2's default shell is bash-- if you're > using some other shell, consult the manpage for the proper file and > command syntax for setting the environment. > > Thanks for your reply but the .bashrc seems to me the wrong place to set the DISPLAY variable. If you login from another machine it won't be set properly. Pepijn. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-16 14:51 ` Pepijn Kenter @ 2003-12-16 16:26 ` gebser 2003-12-17 6:42 ` Maurizio Loreti 1 sibling, 0 replies; 13+ messages in thread From: gebser @ 2003-12-16 16:26 UTC (permalink / raw) At 15:51 (UTC+0100) on Tue, 16 Dec 2003 Pepijn Kenter said: = gebser@speakeasy.net wrote: = > There's two ways which will keep/set the DISPLAY variable: = > = > First, if the DISPLAY variable is set in user1 and you do "su user2", = > then the environment of user1 will carry into user2. IOW, you're good. = > = > Second, if you, instead, do "su - user2", then you will have a fresh = > environment, that of user2. If user2's environment doesn't have the = > DISPLAY variable set properly, you can do this by setting this in = > user2's ~/.bashrc file... if user2's default shell is bash-- if you're = > using some other shell, consult the manpage for the proper file and = > command syntax for setting the environment. = > = > = Thanks for your reply but the .bashrc seems to me the wrong place to set = the DISPLAY variable. = If you login from another machine it won't be set properly. = = Pepijn. Obviously you have to edit the ~/.bashrc file on the box and for the account you're logging into. If it doesn't work, you're doing something wrong. Do you know that you're using the bash shell? If so, do "man bash" and it'll tell you about .bashrc and setting env vars. ken ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-16 14:51 ` Pepijn Kenter 2003-12-16 16:26 ` gebser @ 2003-12-17 6:42 ` Maurizio Loreti 2003-12-17 15:34 ` gebser 1 sibling, 1 reply; 13+ messages in thread From: Maurizio Loreti @ 2003-12-17 6:42 UTC (permalink / raw) Pepijn Kenter <kenter_remove_spam@tpd.tno.nl> writes: > gebser@speakeasy.net wrote: > > There's two ways which will keep/set the DISPLAY variable: > > First, if the DISPLAY variable is set in user1 and you do "su > > user2", then the environment of user1 will carry into user2. IOW, > > you're good. Second, if you, instead, do "su - user2", then you will > > have a fresh environment, that of user2. If user2's environment > > doesn't have the DISPLAY variable set properly, you can do this by > > setting this in user2's ~/.bashrc file... if user2's default shell > > is bash-- if you're using some other shell, consult the manpage for > > the proper file and command syntax for setting the environment. > > > Thanks for your reply but the .bashrc seems to me the wrong place to > set the DISPLAY variable. > If you login from another machine it won't be set properly. Correct. The right place is .bash_profile, executed at login. FWIW, this is from my own .bash_profile: ,----- | # Tries to figure out a correct DISPLAY environment variable | | if [ -n "$DISPLAY" ] | then | # if DISPLAY is set, we assume it is also valid; if it is not, | # the user may always change it later ($DISPLAY is printed at | # the end of the login procedure). | | REMOTE="${DISPLAY%%:*}" | else | temp0=$(who am i | awk '{print $2}') | | if [ "$temp0" = "console" ] | then | REMOTE="localhost" | DISPLAY=":0.0" | else | temp1=$(who --lookup | grep "$temp0 " | uniq | awk '{print $6}') | # Note the blank-------------------^ | if [ -n "$temp1" ] | then | temp2=$(echo $temp1 | sed -e 's/(//' -e 's/)//') | temp3=$(echo $temp2 | cut -d. -f2) | if [ "$temp3" = "pd" ] | then | # If on host.pd.infn.it, DISPLAY="host:0.0"; | # if not, DISPLAY="host.dom.ain:0.0" | REMOTE=$(echo $temp2 | cut -d. -f1) | else | REMOTE="${temp2%%:*}" | fi | DISPLAY="${REMOTE}:0.0" | unset temp2 temp3 | else | REMOTE="" | DISPLAY=":0.0" | fi | unset temp1 | fi | unset temp0 | fi | | export REMOTE DISPLAY | echo "DISPLAY is now: $DISPLAY" `----- -- Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html Dept. of Physics, Univ. of Padova, Italy ROT13: ybergv@cq.vasa.vg ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-17 6:42 ` Maurizio Loreti @ 2003-12-17 15:34 ` gebser 0 siblings, 0 replies; 13+ messages in thread From: gebser @ 2003-12-17 15:34 UTC (permalink / raw) Cc: help-gnu-emacs Of course everyone can set up their systems however they wish, but I use: export DISPLAY=$(who -lum|awk -F '(' '{print $2}'|awk -F ')' '{print $1}'):0 in my ~/.bashrc and have no problem logging in and/or running remotely whatever X apps I want. Because it would take a lot of thinking to hash out which is the correct file to put this in, whether the DISPLAY is a resource or not, whether this variable should be set for all interactive shells or just for logins, and because I don't wish to argue any of this, I'll just say that I disagree and believe that .bashrc *is* the proper place for setting DISPLAY. As said at the outset, everyone can set up their systems however they wish. hth, ken At 07:42 (UTC+0100) on 17 Dec 2003 Maurizio Loreti said: = Pepijn Kenter <kenter_remove_spam@tpd.tno.nl> writes: = = > gebser@speakeasy.net wrote: = > > There's two ways which will keep/set the DISPLAY variable: = > > First, if the DISPLAY variable is set in user1 and you do "su = > > user2", then the environment of user1 will carry into user2. IOW, = > > you're good. Second, if you, instead, do "su - user2", then you will = > > have a fresh environment, that of user2. If user2's environment = > > doesn't have the DISPLAY variable set properly, you can do this by = > > setting this in user2's ~/.bashrc file... if user2's default shell = > > is bash-- if you're using some other shell, consult the manpage for = > > the proper file and command syntax for setting the environment. = > > = > Thanks for your reply but the .bashrc seems to me the wrong place to = > set the DISPLAY variable. = > If you login from another machine it won't be set properly. = = Correct. The right place is .bash_profile, executed at login. = = FWIW, this is from my own .bash_profile: = = ,----- = | # Tries to figure out a correct DISPLAY environment variable = | = | if [ -n "$DISPLAY" ] = | then = | # if DISPLAY is set, we assume it is also valid; if it is not, = | # the user may always change it later ($DISPLAY is printed at = | # the end of the login procedure). = | = | REMOTE="${DISPLAY%%:*}" = | else = | temp0=$(who am i | awk '{print $2}') = | = | if [ "$temp0" = "console" ] = | then = | REMOTE="localhost" = | DISPLAY=":0.0" = | else = | temp1=$(who --lookup | grep "$temp0 " | uniq | awk '{print $6}') = | # Note the blank-------------------^ = | if [ -n "$temp1" ] = | then = | temp2=$(echo $temp1 | sed -e 's/(//' -e 's/)//') = | temp3=$(echo $temp2 | cut -d. -f2) = | if [ "$temp3" = "pd" ] = | then = | # If on host.pd.infn.it, DISPLAY="host:0.0"; = | # if not, DISPLAY="host.dom.ain:0.0" = | REMOTE=$(echo $temp2 | cut -d. -f1) = | else = | REMOTE="${temp2%%:*}" = | fi = | DISPLAY="${REMOTE}:0.0" = | unset temp2 temp3 = | else = | REMOTE="" = | DISPLAY=":0.0" = | fi = | unset temp1 = | fi = | unset temp0 = | fi = | = | export REMOTE DISPLAY = | echo "DISPLAY is now: $DISPLAY" = `----- = = ^ permalink raw reply [flat|nested] 13+ messages in thread
* GNU emacs locks files modified with CVS @ 2003-12-15 12:25 Pepijn Kenter 2003-12-15 18:04 ` Kevin Rodgers 0 siblings, 1 reply; 13+ messages in thread From: Pepijn Kenter @ 2003-12-15 12:25 UTC (permalink / raw) Hi all. I've got a problem when I use su to log in as another user and try to edit a file that is modified in CVS. Let me show you the sequence of commands that leads to the problem. When loged in as user1 type: su user2 emacs file.pro # edit, exit and save the changes emacs file.pro # file.pro is now read only. I can not edit file.pro the second time because it is apperently locked by user2 (as shown in the status line? of emacs). File permissions are correct and the onwner of file.pro (still) is user2. After some googling I think the possible cause is that emacs is inconsistent in the way it handles the USER and LOGNAME variables. Indeed USER is set to user2 whereas LOGNAME is still user1. When I change LOGNAME to user2 the problem disappears. So, what to do? I've found a very old message (1994) with a patch to solve this problem http://groups.google.nl/groups?q=LOGNAME+USER+emacs&hl=nl&lr=lang_de|lang_en|lang_nl&ie=UTF-8&oe=UTF-8&selm=9402100649.AA13033%40spot.twinsun.com&rnum=1 but I would expect that after all most 10 years the problem had been fixed. A simpler solution would be to set the LOGNAME variable to user2 somewhere. I've understood that the differences are mainly historical. This seems to me an ugly work arround that may leed to problems elsewhere, so I prefer a more elegant solution. Any help would be appriciated. Pepijn Kenter. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-15 12:25 Pepijn Kenter @ 2003-12-15 18:04 ` Kevin Rodgers 2003-12-16 9:44 ` Pepijn Kenter 0 siblings, 1 reply; 13+ messages in thread From: Kevin Rodgers @ 2003-12-15 18:04 UTC (permalink / raw) Pepijn Kenter wrote: > When loged in as user1 type: > su user2 > emacs file.pro # edit, exit and save the changes > emacs file.pro # file.pro is now read only. > > I can not edit file.pro the second time because it is apperently locked > by user2 (as shown in the status line? of emacs). File permissions are > correct and the onwner of file.pro (still) is user2. > > After some googling I think the possible cause is that emacs is > inconsistent in the way it handles the USER and LOGNAME variables. > Indeed USER is set to user2 whereas LOGNAME is still user1. When I > change LOGNAME to user2 the problem disappears. > > So, what to do? If you want a login shell as user2, use `su - user2`. -- Kevin Rodgers ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-15 18:04 ` Kevin Rodgers @ 2003-12-16 9:44 ` Pepijn Kenter 2003-12-16 14:10 ` gebser 0 siblings, 1 reply; 13+ messages in thread From: Pepijn Kenter @ 2003-12-16 9:44 UTC (permalink / raw) Kevin Rodgers wrote: > Pepijn Kenter wrote: > >> When loged in as user1 type: >> su user2 >> emacs file.pro # edit, exit and save the changes >> emacs file.pro # file.pro is now read only. >> >> I can not edit file.pro the second time because it is apperently >> locked by user2 (as shown in the status line? of emacs). File >> permissions are correct and the onwner of file.pro (still) is user2. >> >> After some googling I think the possible cause is that emacs is >> inconsistent in the way it handles the USER and LOGNAME variables. >> Indeed USER is set to user2 whereas LOGNAME is still user1. When I >> change LOGNAME to user2 the problem disappears. >> >> So, what to do? > > > If you want a login shell as user2, use `su - user2`. > I'm sorry, I should have mentioned that I tried that, but then my DISPLAY environment variable is not set so I can not use the graphical emacs. I can, of course, set DISPLAY manually but it would be a nuisance to do that every time I log in as user2. It's not quit clear to me when I should use a login shell and when not. IMO the bash documentation only explaines the differences, not why the different shells exist. I'm guessing the solution will involve tweeking my system, not my emacs settings, so I probably should go to another newsgroup. Still, any help from here would be appreciated. E.g. where is the DISPLAY variable set normally (when I log in as user1)? I'm using debian linux. Pepijn Kenter. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GNU emacs locks files modified with CVS 2003-12-16 9:44 ` Pepijn Kenter @ 2003-12-16 14:10 ` gebser 0 siblings, 0 replies; 13+ messages in thread From: gebser @ 2003-12-16 14:10 UTC (permalink / raw) There's two ways which will keep/set the DISPLAY variable: First, if the DISPLAY variable is set in user1 and you do "su user2", then the environment of user1 will carry into user2. IOW, you're good. Second, if you, instead, do "su - user2", then you will have a fresh environment, that of user2. If user2's environment doesn't have the DISPLAY variable set properly, you can do this by setting this in user2's ~/.bashrc file... if user2's default shell is bash-- if you're using some other shell, consult the manpage for the proper file and command syntax for setting the environment. hth, ken At 10:44 (UTC+0100) on Tue, 16 Dec 2003 Pepijn Kenter said: = Kevin Rodgers wrote: = > Pepijn Kenter wrote: = > = >> When loged in as user1 type: = >> su user2 = >> emacs file.pro # edit, exit and save the changes = >> emacs file.pro # file.pro is now read only. = >> = >> I can not edit file.pro the second time because it is apperently = >> locked by user2 (as shown in the status line? of emacs). File = >> permissions are correct and the onwner of file.pro (still) is user2. = >> = >> After some googling I think the possible cause is that emacs is = >> inconsistent in the way it handles the USER and LOGNAME variables. = >> Indeed USER is set to user2 whereas LOGNAME is still user1. When I = >> change LOGNAME to user2 the problem disappears. = >> = >> So, what to do? = > = > = > If you want a login shell as user2, use `su - user2`. = > = = I'm sorry, I should have mentioned that I tried that, but then my = DISPLAY environment variable is not set so I can not use the graphical = emacs. I can, of course, set DISPLAY manually but it would be a nuisance = to do that every time I log in as user2. = = It's not quit clear to me when I should use a login shell and when not. = IMO the bash documentation only explaines the differences, not why the = different shells exist. = = I'm guessing the solution will involve tweeking my system, not my emacs = settings, so I probably should go to another newsgroup. Still, any help = from here would be appreciated. = = E.g. where is the DISPLAY variable set normally (when I log in as = user1)? I'm using debian linux. = = Pepijn Kenter. = = _______________________________________________ = Help-gnu-emacs mailing list = Help-gnu-emacs@gnu.org = http://mail.gnu.org/mailman/listinfo/help-gnu-emacs = ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2003-12-18 17:19 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <mailman.195.1071679031.868.help-gnu-emacs@gnu.org> 2003-12-17 16:26 ` GNU emacs locks files modified with CVS Kevin Rodgers 2003-12-17 19:03 ` gebser 2003-12-17 16:41 ` Pepijn Kenter 2003-12-17 17:54 ` Maurizio Loreti 2003-12-18 17:19 ` Kevin Rodgers [not found] <mailman.138.1071587578.868.help-gnu-emacs@gnu.org> 2003-12-16 14:51 ` Pepijn Kenter 2003-12-16 16:26 ` gebser 2003-12-17 6:42 ` Maurizio Loreti 2003-12-17 15:34 ` gebser 2003-12-15 12:25 Pepijn Kenter 2003-12-15 18:04 ` Kevin Rodgers 2003-12-16 9:44 ` Pepijn Kenter 2003-12-16 14:10 ` gebser
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).