Diffs to the Frequently Asked Questions postings

Steve Hayman sahayman at iuvax.cs.indiana.edu
Tue Feb 5 04:12:19 AEST 1991


Here are the most recent changes to parts 1 and 2 of the
Frequently Asked Questions articles, which have just been
posted.  You can find the full articles elsewhere in
comp.unix.questions.  You can also ftp the most recent version from
iuvax.cs.indiana.edu (129.79.254.192), where it's
"pub/Unix-Questions.part1" and "pub/Unix-Questions.part2".
(IUVax also runs a mail server, for those of you unable to ftp.
 Send the line "HELP" to "mailserv at iuvax.cs.indiana.edu" to get started.)

*** /tmp/,RCSt1a23400	Mon Feb  4 12:11:35 1991
--- part2	Mon Feb  4 12:11:25 1991
***************
*** 1,6 ****
  Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting]
  
! [Last changed: $Date: 91/01/03 14:27:19 $ by $Author: sahayman $]
  
  This article contains the answers to some Frequently Asked Questions
  often seen in comp.unix.questions.  Please don't ask these questions
--- 1,6 ----
  Subject: Frequently Asked Questions about Unix - with Answers [Monthly posting]
  
! [Last changed: $Date: 91/02/04 12:11:11 $ by $Author: sahayman $]
  
  This article contains the answers to some Frequently Asked Questions
  often seen in comp.unix.questions.  Please don't ask these questions
***************
*** 54,60 ****
  	30) What are some useful Unix or C books?
  	31) How do I construct a shell glob-pattern that matches all files
  	    except "." and ".." ?
! 	32) How do I pronounce "vi" , or "!", or "/*", or ...?
  
  
      If you're looking for the answer to, say, question 14, and want to skip
--- 54,61 ----
  	30) What are some useful Unix or C books?
  	31) How do I construct a shell glob-pattern that matches all files
  	    except "." and ".." ?
! 	32) How do I find the last argument in a Bourne shell script?
! 	33) How do I pronounce "vi" , or "!", or "/*", or ...?
  
  
      If you're looking for the answer to, say, question 14, and want to skip
***************
*** 1242,1247 ****
--- 1243,1254 ----
  	    return select( 0, (long *)0, (long *)0, (long *)0, &delay );
  	    }
  
+     Another possibility for nap()ing on System V, and probably other
+     non-BSD Unices is Jon Zeeff's s5nap package, posted to
+     comp.sources.misc, volume 4.  It does require a installing
+     a device driver, but works flawlessly once installed.
+     (Its resolution is limited to the kernel HZ value, since it
+     uses the kernel delay() routine.)
  
  29) How can I get setuid shell scripts to work?
  
***************
*** 1429,1436 ****
  
      but even it will mess up on files with newlines in their names.
  
! 32) How do I pronounce "vi" , or "!", or "/*", or ...?
  
      You can start a very long and pointless discussion by wondering
      about this topic on the net.  Some people say "vye", some say
      "vee-eye" (the vi manual suggests this) and some Roman numerologists
--- 1436,1544 ----
  
      but even it will mess up on files with newlines in their names.
  
! 32) How do I find the last argument in a Bourne shell script?
  
+     Answer by:
+ 	Martin Weitzel <@mikros.systemware.de:martin at mwtech.uucp>
+ 	Maarten Litmaath <maart at cs.vu.nl>
+ 
+     If you are sure the number of arguments is at most 9, you can use:
+ 
+ 	eval last=\${$#}
+ 
+     In POSIX-compatible shells it works for ANY number of arguments.
+     The following works always too:
+ 
+ 	for last
+ 	do
+ 		:
+ 	done
+ 
+     This can be generalized as follows:
+ 
+ 	for i
+ 	do
+ 		third_last=$second_last
+ 		second_last=$last
+ 		last=$i
+ 	done
+ 
+     Now suppose you want to REMOVE the last argument from the list,
+     or REVERSE the argument list, or ACCESS the N-th argument directly,
+     whatever N may be.  Here is a basis of how to do it, using only
+     built-in shell constructs, without creating subprocesses:
+ 
+ 	t0= u0= rest='1 2 3 4 5 6 7 8 9' argv=
+ 
+ 	for h in '' $rest
+ 	do
+ 		for t in "$t0" $rest
+ 		do
+ 			for u in $u0 $rest
+ 			do
+ 				case $# in
+ 				0)
+ 					break 3
+ 				esac
+ 				eval argv$h$t$u=\$1
+ 				argv="$argv \"\$argv$h$t$u\""	# (1)
+ 				shift
+ 			done
+ 			u0=0
+ 		done
+ 		t0=0
+ 	done
+ 
+ 	# now restore the arguments
+ 	eval set x "$argv"					# (2)
+ 	shift
+ 
+     This example works for the first 999 arguments.  Enough?
+     Take a good look at the lines marked (1) and (2) and convince yourself
+     that the original arguments are restored indeed, no matter what funny
+     characters they contain!
+ 
+     To find the N-th argument now you can use this:
+ 
+ 	eval argN=\$argv$N
+ 
+     To reverse the arguments the line marked (1) must be changed to:
+ 
+ 	argv="\"\$argv$h$t$u\" $argv"
+ 
+     How to remove the last argument is left as an exercise.
+ 
+     If you allow subprocesses as well, possibly executing nonbuilt-in
+     commands, the `argvN' variables can be set up more easily:
+ 
+ 	N=1
+ 
+ 	for i
+ 	do
+ 		eval argv$N=\$i
+ 		N=`expr $N + 1`
+ 	done
+ 
+     To reverse the arguments there is still a simpler method, that even does
+     not create subprocesses.  This approach can also be taken if you want
+     to delete e.g. the last argument, but in that case you cannot refer
+     directly to the N-th argument anymore, because the `argvN' variables are
+     set up in reverse order:
+ 
+ 	argv=
+ 
+ 	for i
+ 	do
+ 		eval argv$#=\$i
+ 		argv="\"\$argv$#\" $argv"
+ 		shift
+ 	done
+ 
+ 	eval set x "$argv"
+ 	shift
+ 
+ 33) How do I pronounce "vi" , or "!", or "/*", or ...?
+ 
      You can start a very long and pointless discussion by wondering
      about this topic on the net.  Some people say "vye", some say
      "vee-eye" (the vi manual suggests this) and some Roman numerologists
***************
*** 1449,1455 ****
  
  			The Pronunciation Guide
  			-----------------------
! 			      version 2.4
  
  Names derived from UNIX are marked with *, names derived from C are marked
  with +, names derived from (Net)Hack are marked with & and names deserving
--- 1557,1563 ----
  
  			The Pronunciation Guide
  			-----------------------
! 			      version 2.5
  
  Names derived from UNIX are marked with *, names derived from C are marked
  with +, names derived from (Net)Hack are marked with & and names deserving
***************
*** 1547,1553 ****
  
  `    GRAVE, (grave/acute) accent, backquote, left/open quote, backprime, 
  	unapostrophe, backspark, birk, blugle, backtick, push, backglitch,
! 	backping, execute#, boulder&, rock&
  
  {}   BRACES, curly braces, squiggly braces, curly brackets, squiggle brackets,
  	Tuborgs#, ponds, curly chevrons#, squirrly braces, hitchcocks#,
--- 1655,1661 ----
  
  `    GRAVE, (grave/acute) accent, backquote, left/open quote, backprime, 
  	unapostrophe, backspark, birk, blugle, backtick, push, backglitch,
! 	backping, execute#, boulder&, rock&, blip
  
  {}   BRACES, curly braces, squiggly braces, curly brackets, squiggle brackets,
  	Tuborgs#, ponds, curly chevrons#, squirrly braces, hitchcocks#,



More information about the Comp.unix.questions mailing list