delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/12/11:32:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Mon, 12 May 2003 11:32:24 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Sylvain DOT Ferriol AT imag DOT fr
cc: cygwin AT cygwin DOT com
Subject: Re: suggestion for cygutils - usermod (was Re: howto change home
path in /etc/passwd)
In-Reply-To: <Pine.GSO.4.44.0305121112360.393-100000@slinky.cs.nyu.edu>
Message-ID: <Pine.GSO.4.44.0305121130090.393-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Mon, 12 May 2003, Igor Pechtchanski wrote:

> On Mon, 12 May 2003 Sylvain DOT Ferriol AT imag DOT fr wrote:
>
> > Surlignage Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>:
> >
> > > On Mon, 12 May 2003 Sylvain DOT Ferriol AT imag DOT fr wrote:
> > >
> > > > Surlignage Max Bowsher <maxb AT ukf DOT net>:
> > > >
> > > > > Sylvain DOT Ferriol AT imag DOT fr wrote:
> > > > > > Yes , because i don't want to create a shell doing this:
> > > > > > grep -v $USERNAME /etc/passwd > /etc/passwd
> > > > >
> > > > sorry
> > > > but i don't know with sed how to delete a line starting with $USER
> > >
> > > For the record: "sed '/'$USER':/d".  However, grep is perfectly adequate.
> > > What Max was warning you about was the shell redirection mechanism.  You'd
> > > be safer using something like
> > >
> > >   cp -p /etc/passwd /etc/passwd-bak-tmp && grep -v $USERNAME
> > > /etc/passwd-bak-tmp > /etc/passwd && rm -f /etc/passwd-bak-tmp
> > >
> > is it better to use $USER or $USERNAME??
> >
> > sylvain
>
> $USERNAME is set by Windows.  $USER is set by /etc/profile to the output
> of "id -un".  They should be the same in most cases (they even seem to be
> the same if "login" is used to switch user contexts from a SYSTEM-owned
> shell -- go figure).  Which would be better depends on the purpose, I
> guess...
>         Igor

Sylvain,

FYI, $USERNAME doesn't seem to be set if the user is not a "real" user,
e.g., SYSTEM:

C:\> at 11:30 /interactive c:\cygwin\bin\bash.exe --login -i

Then from the bash window:

$ set | grep '^U'
UID=18
USER=SYSTEM
USERPROFILE='C:\Documents and Settings\Default User'

> > > > > Care! That will leave you with an empty /etc/passwd.
> > > > > The shell truncates /etc/passwd BEFORE grep reads it.
> > > > >
> > > > > > mkpasswd -l -u $USERNAME -p $HOME >> /etc/passwd
> > > > >
> > > > > Max.

	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Knowledge is an unending adventure at the edge of uncertainty.
  -- Leto II


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019