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:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=Fbt9C4jn2InF/b1QtW8Bk5jRFKLJGHtWzHSHo6IgIrlZLWmeGbIhG ETWlyloiRIJthrNp/OxwpPotUk7TDVtyVm7QDZLDv4JRFlhmbPzZrfU7XUk3aYCw rHEonfJRWRb99Viz7qhnKXhVUtuXVyOuDAKYIJhUqDOTLUQ/S6bXOw= 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:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=TE8JxvHiHxhf9woZ8v0T6X7e3Qc=; b=sNprRXR087Snhdk0AgN6KrzwmvlL GgfDfhlhMUlqZ5y8/HCNmNpRROlgm90Xe+HZ/804+blq0Q3dPM/SXRPuF99355Tc JyZsfl3yzrpOwn6HRLF9/Q35zaMgflA++FfGxAuT2gOIrQdD7PyoPW3XRGBPglxv lNQGRJNggEprIqs= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-94.7 required=5.0 tests=BAYES_40,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_PBL,RDNS_DYNAMIC,USER_IN_WHITELIST autolearn=no version=3.3.2 spammy=Hx-languages-length:1310, schulman, Schulman, HX-Envelope-From:sk:corinna X-HELO: calimero.vinschen.de Date: Tue, 15 Mar 2016 18:08:19 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Change PS1 when run as administrator Message-ID: <20160315170819.GA11488@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <98egebtkn3kakah2g5m9nhr393mag7qm8j AT 4ax DOT com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <98egebtkn3kakah2g5m9nhr393mag7qm8j@4ax.com> User-Agent: Mutt/1.5.24 (2015-08-30) --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mar 15 12:33, Andrew Schulman wrote: > > I just came up with this recipe to change the default PS1 value to use = red for the user AT host part of the prompt and to change the $ character to a= #: > >=20 > > if id | grep -qi 'member of administrators group' > > then > > export PS1=3D$(echo "$PS1" | sed -e 's_32_31_' -e 's_\\\$_#_') > > fi > >=20 > > I=C2=92m not certain the string match on the output of id(1) works ever= ywhere. Is there a better way to check for admin privileges under Cygwin? = You can=C2=92t check for UID or EUID =3D=3D 0, for example, as you=C2=92d = do on a true POSIX system. >=20 > Ha! Yes, there is: see > https://cygwin.com/ml/cygwin/2015-02/msg00057.html. The magic test is >=20 > id -G | grep -qE '\<(544|0)\>' >=20 > where 544 is the Administrators group, and 0 is the root group in case the > old root group entry is present in /etc/group. >=20 > For example: >=20 > id -G | grep -qE '\<(544|0)\>' && echo admin || echo user Thou shalt not use the test for gid 0 anymore. If it works, remove the entry from /etc/group, or better, remove /etc/group entirely. This entry will render wrong and unwanted results when you least expect them. Such cruft always does. Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --Q68bSM7Ycu6FN28Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJW6EGDAAoJEPU2Bp2uRE+gfqEP/jKpC0nOQ6aI+h1V0qd7KJFq qjegwBu2Q/a7n5KI72N3EeklknWpVbyu+6HcNVFcVSWdETt4TWjfukOZ1FnyAMHq pQmo8Glv5NMmrtilhjLW4HgB56+bWWZeF1lfaXAQxYPYP5uJCr46HBfIX5+uzgg7 ujyHur6aKZjtIdt+2CdcA0OBTRzI39Jn4cHjdCuvZFqLGvpefRR6UCgR81J7dAp7 AOGPFSO738gXaRUwQmcTBg47AVJG7qAUJna2JONQ7dAX5qplGx/8YByusUPrvK26 dAHEz/rTlLNUiZYmOjzA/E9Kz9C3GuRIS6a/0TiAHSukk148NBHRn2KUatABNRtd nyxAi6yv7BHdagrU2fIuUZQf36VVdvfAtxmYcJT8Yxt76lfiHpnRsmZltDnd5izt aAvtbACe/6/ZBk2N3gGE49A0nr6Ib9+CEANDbPZUoXIsA3STLNn8pgOKPxjIN4NX rz0uNulzPX9IW7ld7pYuWAtNpXC4FzPPcEcigqKZgaDU/jpdfENl/xtHaoxsa+k+ QJwOvOp8Q4GgGCWq+f3YQUcB6kz4H5qSBycHYfl70DXVldHOl7YUKINx94wA/hnD gZ2a6ovjayxLzQ2dXQlJ/c6TB4N3tsDIc8Z2RzaQz8xpmGs9l0XqMuOHiTc4VqD7 OKZhU3FfkOh2PH7nNRLv =RBeP -----END PGP SIGNATURE----- --Q68bSM7Ycu6FN28Q--