Index: ossp-pkg/shtool/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/shtool/ChangeLog,v rcsdiff -q -kk '-r1.152' '-r1.153' -u '/v/ossp/cvs/ossp-pkg/shtool/ChangeLog,v' 2>/dev/null --- ChangeLog 2001/06/13 08:54:50 1.152 +++ ChangeLog 2001/06/13 21:30:05 1.153 @@ -9,7 +9,11 @@ ChangeLog - Changes between 1.5.3 and 1.5.4 (19-Apr-2001 to xx-May-2001): + Changes between 1.5.3 and 1.5.4 (19-Apr-2001 to xx-Jun-2001): + + *) Added %g (current group name) and %G (current group id) + constructs to `shtool echo -e' command. + [Ralf S. Engelschall] *) Fixed example of `shtool move' in shtool.pod [Ralf S. Engelschall] Index: ossp-pkg/shtool/sh.echo RCS File: /v/ossp/cvs/ossp-pkg/shtool/sh.echo,v rcsdiff -q -kk '-r1.25' '-r1.26' -u '/v/ossp/cvs/ossp-pkg/shtool/sh.echo,v' 2>/dev/null --- sh.echo 2001/06/13 08:54:50 1.25 +++ sh.echo 2001/06/13 21:30:05 1.26 @@ -99,7 +99,7 @@ # determine user name username='' -if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then +if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uUgG]'`" != . ]; then username="$LOGNAME" if [ ".$username" = . ]; then username="$USER" @@ -141,6 +141,35 @@ fi fi +# determine (primary) group id +groupid='' +if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[gG]'`" != . ]; then + groupid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \ + sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` + if [ ".$groupid" = . ]; then + groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \ + sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'` + if [ ".$groupid" = . ]; then + groupid='?' + fi + fi +fi + +# determine (primary) group name +groupname='' +if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%g'`" != . ]; then + groupname=`egrep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \ + sed -e 's/:.*$//'` + if [ ".$groupname" = . ]; then + groupname=`(ypcat group) 2>/dev/null | \ + egrep "^[^:]*:[^:]*:${groupid}:" | \ + sed -e 's/:.*$//'` + if [ ".$groupname" = . ]; then + groupname='?' + fi + fi +fi + # determine host and domain name hostname='' domainname='' @@ -220,6 +249,8 @@ -e "s/%b/${term_norm}/g" \ -e "s/%u/${username}/g" \ -e "s/%U/${userid}/g" \ + -e "s/%g/${groupname}/g" \ + -e "s/%G/${groupid}/g" \ -e "s/%h/${hostname}/g" \ -e "s/%d/${domainname}/g" \ -e "s/%D/${time_day}/g" \ Index: ossp-pkg/shtool/shtool.pod RCS File: /v/ossp/cvs/ossp-pkg/shtool/shtool.pod,v rcsdiff -q -kk '-r1.50' '-r1.51' -u '/v/ossp/cvs/ossp-pkg/shtool/shtool.pod,v' 2>/dev/null --- shtool.pod 2001/06/13 08:54:50 1.50 +++ shtool.pod 2001/06/13 21:30:05 1.51 @@ -294,15 +294,17 @@ character (``C<\n>''). When option ``B<-n>'' is used this newline character is left out. -The I can contain special ``B<%>I'' constructs which which are -expanded before the output is written if option ``B<-e>'' is used. -Currently the following constructs are recognized: ``B<%B>'' for switching to -terminal bold mode, ``B<%b>'' for switching terminal mode back to normal -display mode, ``B<%u>'' for the current user name, ``B<%U>'' for the current -user id (numerical), ``B<%h>'' for the current hostname, ``B<%d>'' for the -current domain name, ``B<%D>'' for the current day of the month, ``B<%M>'' for -the current month (numerical), ``B<%m>'' for the current month name and -``B<%Y>'' for the current year. +The I can contain special ``B<%>I'' constructs which which +are expanded before the output is written if option ``B<-e>'' is +used. Currently the following constructs are recognized: ``B<%B>'' +for switching to terminal bold mode, ``B<%b>'' for switching terminal +mode back to normal display mode, ``B<%u>'' for the current user name, +``B<%U>'' for the current user id (numerical), ``B<%g>'' for the current +group name, ``B<%G>'' for the current group id (numerical), ``B<%h>'' +for the current hostname, ``B<%d>'' for the current domain name, +``B<%D>'' for the current day of the month, ``B<%M>'' for the current +month (numerical), ``B<%m>'' for the current month name and ``B<%Y>'' +for the current year. The trick of this command is that it provides a portable ``B<-n>'' option and hides the gory details needed to find out the environment details.