This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: dodgy chere (aka cygwin prompt here) feature

Dave wrote on Wednesday, October 06, 2004 1:29 PM :

> Am in the process of adding functionality.
> I have a shiny new feature working locally:
> Context Menu item checks /etc/passwd for the preferred shell of the
> current user, and starts that as a login shell using the specified
> term.
> At the moment it has some quite horrible quoting going on, and
> I'm trying to shoehorn in another exec.
> Does anyone think this is a useful feature? Or is this going to
> be a nightmare to support across multiple platforms?
> The essential command line ignoring (most) quoting issues would
> be something like:
> [term cmd] /bin/sh -c "scmd=`sed -n \"s?$USERNAME:.*:\(.*\)?\1?gp\"
> /etc/passwd`; exec \"$scmd -l -c \"cd '%1'; exec $scmd\"\"\""

Does it really have to be a one-liner?
Why not add a script and call it instead?
This kind of constructs has a tendency to evolve into horrendous quoting,
eventually ending up in maintenance hell.

> Possible issues:
> 1. I'm guessing USERNAME is windows specific and may not be available
> on 9x. Could use id -un at the expense of more quoting/variables. Is
> $USER available in a non-login sh?

> 2. When creating the key, I check /etc/passwd is present. But
> what if something nasty happens to it? Will it always be readable?

> 3. Should we care if someones passwd says user:...:/bin/rm -f *; ?

Use the equivalent of '-f' in bash?
 if [ -f ... ] ;then RUN ; else BAD ;fi
(man bash)

> Comments appreciated.

/Hannu E K Nevalainen, B.Sc. EE Microcomputer systems            --72-->

** mailing list preference; please keep replies on list **

-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]