delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/06/17/15:17:01

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=SPZ8XD
tVZONVfVuhxBauSs7ChjnZ9T0o8f0qWUHI2qOefVlW85qQkFGp4Nc/xSQ+BjkM32
ddnaWcJ5qceubxGcjPr9pRUV+XnIqPcGDu0rxDklDjEBryAjh4JjdO22B7OmoneP
53wz+4UebTkKzIglT4iNJuLKxNaCafiw1rAr0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=lRV31qgNh/rs
9Ck0Mpo7vxgp8dM=; b=iTP0dQ6sCOmxlCni2UnsbxHfhNdrPqvg+VRrqs6UvmYq
AhGydjCbxSQwtKRUr3EVbTYCl74RTBHn+Bwx53KaV30HBDkIm234lgS/23wVhsYV
hXv3/BgtoOH+bRHlnsppgZKVBbfWtvMe65D/aw9j0a6yUNzpzLF1hNh7kb5bnNI=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mx1.redhat.com
Message-ID: <53A09417.8050009@redhat.com>
Date: Tue, 17 Jun 2014 13:16:39 -0600
From: Eric Blake <eblake AT redhat DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Change PS1 when running as administrator
References: <1402994703 DOT 51470 DOT YahooMailNeo AT web172206 DOT mail DOT ir2 DOT yahoo DOT com> <53A06B0D DOT 9050806 AT raelity DOT com>
In-Reply-To: <53A06B0D.9050806@raelity.com>
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
X-IsSubscribed: yes

--Tm6ijhAFkD2uhUQInDguAoGGwe5pFAR4H
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 06/17/2014 10:21 AM, Ernie Rael wrote:
> On 6/17/2014 1:45 AM, GrahamC wrote:
>> If we are looking for other alternatives the GROUPS environment
>> variable can also be used:
>>
>> PS1=3D'\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
>> for G in "${GROUPS[@]}"; do
>>      if [ "$G" =3D 544 ]; then
>>          PS1=3D'\[\e]0;Administrator \w\a\]\n\[\e[32m\]\u@\h
>> \[\e[33m\]\w\[\e[0m\]\n# '
>>      fi
>> done
>=20
> Speaking of alternatives,
>=20
> For matching in bash, something like
>=20
>     [[ $(id -G) =3D~ \b544\b ]]

\b is a glibc regex() extension, not supported in Cygwin regex

Cygwin supports \< as a shortcut for [[:<:]], and \> as a shortcut for
[[:>:]], which are both BSD extensions.  \b is roughly equivalent to
[[:<:][:>:]] - but someone would have to actually patch cygwin's
regcomp.c to enable that extension.

https://cygwin.com/viewvc/src/winsup/cygwin/regex/regcomp.c?view=3Dco&revis=
ion=3D1.16&content-type=3Dtext%2Fplain

>=20
> was suggested (the suggestion used symbolic name instead of a number and
> didn't use word boundary). Seems like word boundary is needed, but I
> couldn't get this to work. Are the regex boundary matchers not
> supported  by bash =3D~ operator?

bash only supports what the libc regex() supports, and since Cygwin
regex() is not as full-featured as glibc regex(), the answer is that you
can't use \b in Cygwin bash (yet; PTC).

--=20
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


--Tm6ijhAFkD2uhUQInDguAoGGwe5pFAR4H
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJToJQXAAoJEKeha0olJ0Nqmx0H/1qDm2oNnrPsOTJdqtkFhXIt
A9thxKmKPSZIUDfh3CUWr9CGGAtZHN4mmsk86Ii1khh7zTBvC2+PnREgK4K+ey0V
3GMpYZ5HoBiqNhQyYHY/pTZJi9Tp3ZZ4h8y3mM8BWkMHVdUgcLppMor3e0Idi2dZ
L7znB91GER5+EA2d0D3kNV9CnLTSbpmTAGBevHnc9zYauM5W1kAV9SdFd0J61C08
EccZMm/9SF4fW5MF6T7Pbs5F9VbxQ60we/kja9FETM52PJw6XWj8Va7P32o8g0UF
B8g/70sgOg58wPkiXgPKGtSCQxn252arXDQspB5XNAt039bswZxjtPqSEEnsXXM=
=LvPa
-----END PGP SIGNATURE-----

--Tm6ijhAFkD2uhUQInDguAoGGwe5pFAR4H--

- Raw text -


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