home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / fb < prev    next >
Encoding:
Text File  |  1997-08-26  |  901 b   |  30 lines

  1. :
  2. # @(#) fb.sh 1.0 93/04/17
  3. # 93/02/24 john h. dubois iii (john@armory.com)
  4. # 93/04/17 Treat each command line arg as a separate equation
  5.  
  6. # fb: invoke bc with scale=10
  7. # bc will not take commands on command line, only the names of files to
  8. # read commands from.
  9. # The following starts a subshell with fd 3 dupped from fd 0 (stdin)
  10. # so that the scale command can be piped to bc on fd 0 and then further
  11. # commands read from the standard input of fb on fd 3.
  12. # The standard input to bc (the scale command) is dupped to fd 4 and
  13. # put on the command line as /dev/fd/4 so that it will be read first;
  14. # fd 0 is then dupped from fd 3, where fb's standard input was preserved.
  15. #alias fb='( echo "scale = 10" | bc /dev/fd/0 /dev/fd/3 ) 3<&0'
  16.  
  17. if [ $# -eq 0 ]; then
  18.     exec bc /dev/fd/3 3<<END_OF_INPUT
  19. scale = 10
  20. END_OF_INPUT
  21. else
  22.     {
  23.     echo "scale = 10"
  24.     for arg
  25.     do
  26.         echo "$arg"
  27.     done
  28.     } | bc
  29. fi
  30.