home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / gaps / part01 < prev    next >
Encoding:
Text File  |  1992-09-19  |  28.7 KB  |  1,038 lines

  1. Newsgroups: comp.sources.misc
  2. From: nyh@gauss.technion.ac.il (Nadav Har'El)
  3. Subject:  v32i088:  gaps - The Get and Put System v5.01, Part01/01
  4. Message-ID: <1992Sep20.235908.5182@sparky.imd.sterling.com>
  5. X-Md4-Signature: e6077f4476cf433f1830985e78b66f57
  6. Date: Sun, 20 Sep 1992 23:59:08 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: nyh@gauss.technion.ac.il (Nadav Har'El)
  10. Posting-number: Volume 32, Issue 88
  11. Archive-name: gaps/part01
  12. Environment: UNIX
  13.  
  14. GAPS - The Get and Put System - is a set of shell scripts for managing 
  15. versions of programs, similar to the idea of RCS or SCCS. But, as opposed 
  16. to those two, the usage of GAPS is very simple and straightforward. The 
  17. shell scripts can be easily ported between unix systems without recompiling, 
  18. and are easy to change if you want to. 
  19.  
  20. For those unfamiliar with the concept of a version history, a complete 
  21. manual gaps.1 is included in this package, which also explains the usage 
  22. of the programs included in this package.
  23.  
  24. In addition to the basic shell script to put a new version in the history,
  25. GAPS includes shell scripts to list versions, Check difference between
  26. versions, change version information, and more.
  27.  
  28. GAPS supports for each version a name (such as 4.23, 11R5, or any kind of
  29. format you choose) which is NOT updated automatically - when putting a new
  30. version in the history file you are told of the last version name, and
  31. asked to choose a new version name. This makes keeping track of version names
  32. much easier then with SCCS, with its cumbersome 'p.' files. It also includes
  33. the ability to write a summary of changes when putting a new version in the
  34. history file, and to change that summary later with the chver program
  35. included.
  36. -------------
  37. #! /bin/sh
  38. # This is a shell archive.  Remove anything before this line, then feed it
  39. # into a shell via "sh file" or similar.  To overwrite existing files,
  40. # type "sh file -c".
  41. # Contents:  README VERSION chver gaps.1 get lastver put unput vcat
  42. #   vdiff ver vls
  43. # Wrapped by kent@sparky on Sun Sep 20 18:51:32 1992
  44. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  45. echo If this archive is complete, you will see the following message:
  46. echo '          "shar: End of archive 1 (of 1)."'
  47. if test -f 'README' -a "${1}" != "-c" ; then 
  48.   echo shar: Will not clobber existing file \"'README'\"
  49. else
  50.   echo shar: Extracting \"'README'\" \(3011 characters\)
  51.   sed "s/^X//" >'README' <<'END_OF_FILE'
  52. X                           GAPS Version 4r22 Readme
  53. X                           ------------------------
  54. X
  55. XGAPS - The Get and Put System - is a set of shell scripts for managing versions
  56. Xof programs, similar to the idea of RCS or SCCS. But, as opposed to those two,
  57. Xthe usage of GAPS is very simple and straightforward. The shell scripts can
  58. Xbe easily ported between unix systems without recompiling, and are easy to
  59. Xchange if you want to. For those unfamiliar with the concept of a version
  60. Xhistory, a complete manual gaps.1 is included in this package, which also
  61. Xexplains the usage of the programs included in this package.
  62. XIn addition to the basic shell script to put a new version in the history,
  63. XGAPS includes shell scripts to list versions, Check difference between
  64. Xversions, change version information, and more.
  65. XGAPS supports for each version a name (such as 4.23, 11R5, or any kind of
  66. Xformat you choose) which is NOT updated automatically - when putting a new
  67. Xversion in the history file you are told of the last version name, and
  68. Xasked to choose a new version name. This makes keeping track of version names
  69. Xmuch easier then with SCCS, with its cumbersome 'p.' files. It also includes
  70. Xthe ability to write a summary of changes when putting a new version in the
  71. Xhistory file, and to change that summary later with the chver program
  72. Xincluded.
  73. XFor more information, read the manual gaps.1 (which should be formatted by
  74. Xtroff -man).
  75. X
  76. XTo install GAPS, simply copy chver, get, lastver, put, unput, vcat, vdiff,
  77. Xver and vls to your favorite bin directory, and gaps.1 to a manual directory,
  78. Xand keep VERSION in if you want to remember what version of GAPS you have.
  79. X
  80. XFiles included in this package
  81. X------------------------------
  82. X
  83. XREADME       - This file
  84. XVERSION      - version information about all the programs included here
  85. Xchver        - Shell script to change version information
  86. Xgaps.1       - GAPS manual
  87. Xget          - Get a version from a history file to the working file
  88. Xlastver      - Return the name of the last version saved in the history file
  89. Xput          - Put a new version of the working file into the history file
  90. Xunput        - Undo a put
  91. Xvcat         - Get a version from a history file to standard output 
  92. Xvdiff        - Check differences between 2 version
  93. Xver          - this is used by other shell scripts, and should be not be used
  94. X           by the user
  95. Xvls          - List versions in a history file
  96. X
  97. XGetting GAPS
  98. X------------
  99. X
  100. XIf you read this readme, you probably have already acquired GAPS. However,
  101. Xif you want to get the newest version of GAPS, the official annonymous ftp site
  102. Xis gauss.technion.ac.il: go to the directory /pub/gaps, and mget gaps*.shar.Z
  103. X
  104. X
  105. XIf you have any questions, comments, wishes for future releases, bug reports,
  106. Xor anything else about GAPS, send them to nyh@gauss.technion.ac.il.
  107. XPlease include in your message the content of your VERSION file, so I will
  108. Xknow exactly which version you have.
  109. X
  110. X
  111. X<<<<<<<<<<<<<INCLUDE SIGNATURE HERE sadlkj >>>>>>>>>>>>>>>>>>>>
  112. END_OF_FILE
  113.   if test 3011 -ne `wc -c <'README'`; then
  114.     echo shar: \"'README'\" unpacked with wrong size!
  115.   fi
  116.   # end of 'README'
  117. fi
  118. if test -f 'VERSION' -a "${1}" != "-c" ; then 
  119.   echo shar: Will not clobber existing file \"'VERSION'\"
  120. else
  121.   echo shar: Extracting \"'VERSION'\" \(179 characters\)
  122.   sed "s/^X//" >'VERSION' <<'END_OF_FILE'
  123. XGAPS Release 4 (Revision 22)
  124. XSunday, September 06, 1992
  125. X
  126. XSource files:
  127. X-------------
  128. Xget 4.1
  129. Xlastver 4.3
  130. Xput 4.3
  131. Xunput 4.2
  132. Xvcat 4.2
  133. Xvdiff 4.2
  134. Xver 4.3
  135. Xvls 4.3
  136. Xchver 4.3
  137. Xgaps.1 4.0
  138. END_OF_FILE
  139.   if test 179 -ne `wc -c <'VERSION'`; then
  140.     echo shar: \"'VERSION'\" unpacked with wrong size!
  141.   fi
  142.   # end of 'VERSION'
  143. fi
  144. if test -f 'chver' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'chver'\"
  146. else
  147.   echo shar: Extracting \"'chver'\" \(3482 characters\)
  148.   sed "s/^X//" >'chver' <<'END_OF_FILE'
  149. X#!/bin/sh
  150. X# GAPS version 4.0
  151. X# get and put system - by Nadav Har'El
  152. X# chver: change version name, and other info
  153. X
  154. XVERSION=0    # current version
  155. XUSAGE="Usage: $0 [-<number version> or -v<named version>] file"
  156. XINPUT=
  157. X
  158. Xwhile test "$1" != ""
  159. Xdo
  160. X    case $1 in
  161. X    -[0-9]|-[0-9][0-9]|-[0-9][0-9][0-9])
  162. X        VERSION=$1;;         # 1-999 versions
  163. X    -v*)    VERSION=$1;;
  164. X    -*)    echo "$USAGE" 2>&1; exit 1;;
  165. X    *)    INPUT=$1
  166. X        case $INPUT in
  167. X        *.H)    ;;
  168. X        *)    INPUT=$INPUT.H ;;
  169. X        esac ;;
  170. X    esac
  171. X    shift
  172. Xdone
  173. Xcase $INPUT in
  174. X"")    echo $USAGE 1>&2; exit 1;;
  175. Xesac
  176. X
  177. Xtest -r $INPUT -a -f $INPUT || { echo "vcat: can't open $INPUT" 1>&2; exit 1; }
  178. X
  179. Xtrap 'rm -f /tmp/chver.[a-g]$$; exit 1' 1 2 3 15
  180. X
  181. Xcase $VERSION in
  182. X-v*)    VERSION=`ver "\`expr \"$VERSION\" : '^-v\(.*\)'\`" $INPUT` || exit 1;;
  183. Xesac
  184. X
  185. Xawk < $INPUT '
  186. X    /^@@\^/    {
  187. X        count++
  188. X        if((count-1)== - '$VERSION')
  189. X            print $0 > "'/tmp/chver.c$$'"
  190. X        else if (count > - '$VERSION')
  191. X            print $0 > "'/tmp/chver.b$$'"
  192. X        else print $0 > "'/tmp/chver.a$$'"
  193. X    }
  194. X    !/^@@\^/ {
  195. X        if(count > - '$VERSION')
  196. X            print $0 > "'/tmp/chver.b$$'"
  197. X        else
  198. X            print $0 > "'/tmp/chver.a$$'"
  199. X    }
  200. X'
  201. X
  202. Xif test ! -f /tmp/chver.c$$
  203. Xthen
  204. X    echo "Chver: no such version $VERSION." 1>&2
  205. X    exit 1
  206. Xfi
  207. X
  208. X#a:    first part to be copied to ouput
  209. X#c:    line edited
  210. X#b:    last part copied to output
  211. X#----------------------------------------
  212. X#d:    version name
  213. X#e:    owner
  214. X#f:    date
  215. X#g:    summary (^ changed to newlines)
  216. X
  217. Xawk -F\^ </tmp/chver.c$$ '
  218. X    {    print $2 > "'/tmp/chver.d$$'"
  219. X        print $3 > "'/tmp/chver.e$$'"
  220. X        print $4 > "'/tmp/chver.f$$'"
  221. X        for(i=5; i<=NF; i++)
  222. X            print $i > "'/tmp/chver.g$$'"
  223. X    }
  224. X'
  225. Xecho "Editing version $VERSION in history file $INPUT."
  226. Xecho "Current version name: `cat /tmp/chver.d$$`"
  227. Xwhile :
  228. Xdo
  229. X    echo -n "Do you want to change the version name (y/n)? "
  230. X    read reply
  231. X    case $reply in
  232. X    y*|Y*)    
  233. X        while :
  234. X        do
  235. X            echo -n 'Version: '
  236. X            read Version
  237. X            case $Version in
  238. X            "")    echo "Chver: NULL version not allowed." 1>&2;;
  239. X            *\^*)    echo "Chver: '^' character not allowed in version." 1>&2;;
  240. X            *)    break;;
  241. X            esac
  242. X        done
  243. X        echo "$Version" > /tmp/chver.d$$
  244. X        break;;
  245. X    n*|N*)    break;;
  246. X    *)    echo "Please enter Yes or No."
  247. X    esac
  248. Xdone
  249. Xecho "Current owner name: `cat /tmp/chver.e$$`"
  250. Xwhile :
  251. Xdo
  252. X    echo -n "Do you want to change the owner name (y/n)? "
  253. X    read reply
  254. X    case $reply in
  255. X    y*|Y*)    
  256. X        while :
  257. X        do
  258. X            echo -n 'Owner: '
  259. X            read Owner
  260. X            case $Owner in
  261. X            *\^*)    echo "Chver: '^' character not allowed in owner." 1>&2;;
  262. X            *)    break;;
  263. X            esac
  264. X        done
  265. X        echo "$Owner" > /tmp/chver.e$$
  266. X        break;;
  267. X    n*|N*)    break;;
  268. X    *)    echo "Please enter Yes or No."
  269. X    esac
  270. Xdone
  271. Xecho "Current summary is:"
  272. Xcat /tmp/chver.g$$
  273. Xwhile :
  274. Xdo
  275. X    echo -n "Do you want to change the summary (y/n)? "
  276. X    read reply
  277. X    case $reply in
  278. X    y*|Y*)    
  279. X        while :
  280. X        do
  281. X            vi /tmp/chver.g$$
  282. X# note: I don't check here is the user removed or did other nasty things to the
  283. X# temporary file. maybe someday I will fix that.
  284. X            if fgrep \^@@\^ /tmp/chver.g$$ >/dev/null
  285. X            then
  286. X                echo "Chver: The string ^@@^ must not appear in the summary."
  287. X                echo "Press enter to edit again."
  288. X                read reply
  289. X                continue
  290. X            fi
  291. X            break
  292. X        done
  293. X        break;;
  294. X    n*|N*)    break;;
  295. X    *)    echo "Please enter Yes or No."
  296. X    esac
  297. Xdone
  298. X
  299. Xtrap '' 1 2 3 15
  300. Xchmod u+w $INPUT
  301. Xcat /tmp/chver.a$$ > $INPUT
  302. Xawk '{printf "@@^%s^",$0}' </tmp/chver.d$$ >>$INPUT
  303. Xawk '{printf "%s^",$0}' </tmp/chver.e$$ >>$INPUT
  304. Xawk '{printf "%s",$0}' </tmp/chver.f$$ >>$INPUT
  305. Xawk '{printf "^%s",$0}' </tmp/chver.g$$ >>$INPUT
  306. Xecho >>$INPUT
  307. Xcat /tmp/chver.b$$ 2>/dev/null >>$INPUT
  308. Xecho Version $VERSION change complete.
  309. Xrm -f /tmp/chver.[a-g]$$
  310. END_OF_FILE
  311.   if test 3482 -ne `wc -c <'chver'`; then
  312.     echo shar: \"'chver'\" unpacked with wrong size!
  313.   fi
  314.   # end of 'chver'
  315. fi
  316. if test -f 'gaps.1' -a "${1}" != "-c" ; then 
  317.   echo shar: Will not clobber existing file \"'gaps.1'\"
  318. else
  319.   echo shar: Extracting \"'gaps.1'\" \(7270 characters\)
  320.   sed "s/^X//" >'gaps.1' <<'END_OF_FILE'
  321. X.TH "GAPS" 1 "version 4.0" "NYH"
  322. X.SH NAME
  323. XGAPS \- Get and put system version 4.0 by Nadav Har'El
  324. X
  325. X.SH SYNOPSIS
  326. X.B chver
  327. X[
  328. X.I version
  329. X]
  330. X.I file
  331. X.br
  332. X.B get
  333. X[
  334. X.I version
  335. X]
  336. X[
  337. X.B -o
  338. X.I outfile
  339. X]
  340. X.I file
  341. X.br
  342. X.B lastver
  343. X.I file
  344. X.br
  345. X.B put
  346. X.I file
  347. X.br
  348. X.B unput
  349. X.I file
  350. X.br
  351. X.B vcat
  352. X[
  353. X.I version
  354. X]
  355. X.I file
  356. X.br
  357. X.B vdiff
  358. X[
  359. X.I version1
  360. X.I version2
  361. X]
  362. X.I file
  363. X.br
  364. X.B vls
  365. X[
  366. X-a
  367. X|
  368. X.I version
  369. X] file
  370. X\&...
  371. X.SH DESCRIPTION
  372. X.\" .TP - indent, and the next line is a subject
  373. X.\" .P - stop TP, new paragraph
  374. X.\" .I - italic
  375. X.\" blank line - new paragraph (no indent)
  376. X.I GAPS
  377. Xis a package for saving a history of the changes to a source code 
  378. Xof a program, or some other ascii file, similar to 
  379. X.I SCCS
  380. Xor
  381. X.IR RCS .
  382. XGAPS allows you to
  383. X.I put
  384. Xa new version, therefore saving the changes from the last version,
  385. X.I get
  386. Xan older version from the history file, and much more. The revision
  387. Xhistory is saved in file.H, where file is the name of the source code
  388. Xor ascii file you are working on.
  389. X
  390. XThe history file has the following structure:
  391. XThe current (last put) version is copied to the beginning of the history
  392. Xfile, and after that follows a list of changes to make the current version
  393. Xinto older versions. Notice that here the current version doesn't necessarily
  394. Xmean the version in the source code file itself, but rather the the version
  395. Xlast put into the history file.
  396. X
  397. XGAPS programs which require a 
  398. X.I version
  399. Xaccept two kinds of version specifications: The first way to specify a
  400. Xversion is by a
  401. X.I number
  402. Xversion. If -0 is used as a 
  403. X.IR version ,
  404. Xit will mean the version last put
  405. Xinto the history file. -1 will mean the previous version, and so on.
  406. XThe second way, which is probably a lot more convenient is using a
  407. X.I named
  408. Xversion. When you use put to put a new version, put tells you the name
  409. Xof the previous version (unless the history file doesn't exist yet)
  410. Xand lets you choose a name for the new version. Typical names are
  411. X1, 1.0, 2.3.4, or such version numbers. Note, that while the
  412. Xversion name may contain spaces, it is recommended
  413. Xto use version names without spaces (although GAPS handles version
  414. Xnames with spaces just as well). When you want to get version 2.3
  415. Xfrom a file, for example, use
  416. X.B get
  417. X-v2.3 file. To see what versions are already saved in the history file,
  418. Xuse the
  419. X.B vls
  420. Xcommand to list the versions saved in the history file. Note that
  421. Xin all the GAPS commands, the file may be specified either by the
  422. Xthe source code's name or the history file (ending with .H) name.
  423. X.B Vls
  424. Xwill list the version history of all the files specified on the command
  425. Xline.
  426. X.BR Vls 's
  427. Xdefault is to list all the versions in the history. If a version (either
  428. X.I number
  429. Xor
  430. X.I named
  431. Xversion) is specified somewhere on the command line, then
  432. X.B vls
  433. Xwill only list versions newer and including the specified version for each
  434. Xof the files after that version option. The special option -a tells
  435. X.B vls
  436. Xto list all the versions in the next history files.
  437. XSome example uses of
  438. X.B vls
  439. Xare:
  440. X
  441. X    vls *.H
  442. X
  443. XTo list all the versions in all history files in the current directory, and
  444. X
  445. X    vls -v8.0 *.H
  446. X
  447. XTo list all versions newer and including version 8.0 for each history file
  448. Xin the current directory, and
  449. X
  450. X    vls file1 -3 file2 file3 -v2.3 file4 -a file5 file6
  451. X
  452. Xto list all versions in file1.H, file2.5 and file6.H, list all versions
  453. Xnewer and including named version 2.3 in file4.H, and to list the newest 4
  454. Xversions
  455. X(all versions newer and including numeric version -3) in file2.H and file3.H.
  456. X
  457. XEvery version in the history file also has a summary, describing
  458. Xthe changes made in that version. When you
  459. X.B put
  460. Xa file, after being asked for the version name, you are asked you for
  461. Xthe version's summary. The summary may be null by simply pressing
  462. X.I ENTER
  463. Xon the prompt, or set to the wanted summary by entering it in.
  464. XNotice that the summary should be a single line. If you want to
  465. Xenter a multiple line summary, use the ^ character wherever you want the
  466. Xline break. For example, if you enter the summary:
  467. X
  468. X    this summary^spans multiple^lines.
  469. X
  470. XThen vls will report the following summary:
  471. X
  472. X    Summary: this summary
  473. X.br
  474. X             spans multiple
  475. X.br
  476. X             lines.
  477. X
  478. X
  479. XEach version also has an owner and a creation date.
  480. X.B Put
  481. Xgets the owner
  482. Xname from the variable LOGNAME, and if it is null or does not exist
  483. Xthen it calls logname and getuid in that order to find the user's login
  484. Xid. The login name must not contain the ^ character, and if it does,
  485. Xthe '?' login name is used instead. Also, the version name must not include
  486. Xthe ^ character.
  487. X
  488. XAll the information about a version, except the creation date can be
  489. Xchanged with the 
  490. X.B chver
  491. Xprogram. It asks you if you want to change the
  492. Xversion name, summary, or owner name, and if you do, it reads new
  493. Xinformation in the version name or owner name case, and lets you to edit with
  494. Xthe
  495. X.I vi
  496. Xeditor the old summary in the summary case.
  497. X
  498. XThe 
  499. X.B get
  500. Xprogram is used to get a version from the history file, and put
  501. Xit in the source code file. The version is specified like before - either
  502. X.RI - n
  503. Xwhere
  504. X.I n
  505. Xis a number, or
  506. X.RI -v name
  507. Xwhere
  508. X.I name
  509. Xis a name of a version.
  510. XAnother option to
  511. X.BR get ,
  512. Xwhich is sometimes needed, is the -o option. This option should be followed
  513. Xby a file name, and specifies the name of the output file, instead of
  514. Xthe file with the same name as the history file, but the .H removed from
  515. Xthe end (the working source file).
  516. XA similar program,
  517. X.BR vcat,
  518. Xis used to look at a version from an history file, but not to write it on
  519. Xa file. The version specified to
  520. X.BR vcat ,
  521. Xalong with the version forms previously described:
  522. X.RI - n
  523. Xand
  524. X.RI -v name ,
  525. Xcan be -c which tells
  526. X.B vcat
  527. Xto simply cat the version you are now working
  528. Xon, i.e. the version which is now in the source code file. This is not
  529. Xvery useful with vcat, but is very useful for
  530. X.BR vdiff .
  531. X.B vdiff
  532. Xis a program to find the difference between two versions in a history file.
  533. XIt uses
  534. X.B vcat
  535. Xso the -c version can be used. Some useful examples of using
  536. X.BR vdiff :
  537. X
  538. X    vdiff -0 -c file
  539. X
  540. Xtells you the changes you have made to the source code file since the last
  541. Xput, and
  542. X
  543. X    vdiff -v1.0 -v2.0 file
  544. X
  545. Xshows you the difference between version 1.0 and 2.0 of the file.
  546. XBecause the first example is so useful, doing simply 'vdiff file', is the
  547. Xsame as 'vdiff -0 -c file'.
  548. X
  549. XAnother useful program provided by GAPS is
  550. X.BR unput ,
  551. Xwhich is used to unput the last (maybe accidentally) put version.
  552. X.B unput
  553. Xcan only remove the last version, and cannot remove it if it is the only
  554. Xversion in the history file. The main use of
  555. X.B unput
  556. Xis after you accidentally use
  557. X.BR put ,
  558. Xand wish you haven't done the put.
  559. X
  560. XAnother program supplied by GAPS is
  561. X.BR lastver ,
  562. Xwhich is used to find the name of the last version in a history file.
  563. X
  564. XThe
  565. X.B GAPS
  566. Xprograms are written entirely as shell scripts, using awk, ed, diff,
  567. Xand other useful UNIX utilities. Therefore, they easily run on most
  568. XUNIX computers.
  569. X.SH "SEE ALSO"
  570. X
  571. Xsccs(1),
  572. Xrcs(1)
  573. X
  574. Xawk(1), cat(1), ed(1), diff(1), sed(1), expr(1), vi(1), sh(1), cp(1),
  575. Xchmod(1), rm(1), test(1), echo(1), grep(1), fgrep(1), logname(1) or
  576. Xgetuid(1)
  577. X
  578. X.SH BUGS
  579. XSummaries which are too long for grep to handle really make GAPS go mad.
  580. X
  581. X.SH COPYRIGHT
  582. XCopyright (C) 1991 by Nadav Har'El,
  583. X.br
  584. XE-mail: nyh@gauss.technion.ac.il
  585. X.br
  586. XAll Rights Reserved
  587. END_OF_FILE
  588.   if test 7270 -ne `wc -c <'gaps.1'`; then
  589.     echo shar: \"'gaps.1'\" unpacked with wrong size!
  590.   fi
  591.   # end of 'gaps.1'
  592. fi
  593. if test -f 'get' -a "${1}" != "-c" ; then 
  594.   echo shar: Will not clobber existing file \"'get'\"
  595. else
  596.   echo shar: Extracting \"'get'\" \(1511 characters\)
  597.   sed "s/^X//" >'get' <<'END_OF_FILE'
  598. X#!/bin/sh
  599. X# GAPS version 4.0
  600. X# get and put system - by Nadav Har'El
  601. X# get: extract file from history
  602. X
  603. XVERSION=0
  604. XINPUT=
  605. XOUTPUT=
  606. XFILEFLG=
  607. XUSAGE="Usage: get [-<number version> or -v<named version>] [-o outfile] file"
  608. X
  609. Xwhile test "$1" != ""
  610. Xdo
  611. X    case "$1" in
  612. X    -o)     OUTPUT=$2; shift ;;
  613. X    -[0-9]|-[0-9][0-9]|-[0-9][0-9][0-9])    VERSION=$1 ;; # 1-999 versions
  614. X    -v*)    VERSION=$1;;
  615. X    -*)     echo "get: unknown argument $i" 1>&2; exit 1 ;;
  616. X    *.H)    case "$FILEFLG" in
  617. X        y)    echo "$USAGE" 1>&2
  618. X            exit 1;;
  619. X        esac
  620. X        FILEFLG=y
  621. X        case "$OUTPUT" in
  622. X        "")    OUTPUT=`expr "$1" : '\(.*\)\.H'`
  623. X        esac
  624. X        INPUT=$1;;
  625. X    *)    case "$FILEFLG" in
  626. X        y)    echo "$USAGE" 1>&2
  627. X            exit 1;;
  628. X        esac
  629. X        FILEFLG=y
  630. X        case "$OUTPUT" in
  631. X        "")    OUTPUT=$1
  632. X        esac
  633. X        INPUT=$1.H
  634. X    esac
  635. X    shift
  636. Xdone
  637. Xcase $FILEFLG in
  638. X"")    echo "$USAGE" 1>&2
  639. X    exit 1;;
  640. Xesac
  641. Xtest -r $INPUT -a -f $INPUT ||
  642. X    { echo "Get: Cannot open $INPUT for input" 1>&2; exit 1; }
  643. Xtest -w $OUTPUT -a ! -d $OUTPUT -o ! -f $OUTPUT -a ! -d $OUTPUT -a \
  644. X    ! -c $OUTPUT -a ! -b $OUTPUT ||
  645. X    { echo "Get: Cannot open $OUTPUT for writing" 1>&2; exit 1; }
  646. Xcase $VERSION in
  647. X-v*)    VERSION=`ver "\`expr \"$VERSION\" : '^-v\(.*\)'\`" $INPUT` || exit 1;;
  648. Xesac
  649. Xtrap 'rm -f /tmp/get.[ab]$$;exit 1' 1 2 3 15
  650. X# split into current version and editing command
  651. Xsed <$INPUT '/^@@\^/q' >/tmp/get.a$$
  652. Xsed <$INPUT -n '/^@@\^/,$w /tmp/get.b'$$
  653. X# preform the edits
  654. Xawk </tmp/get.b$$ '
  655. X    /^@@\^/ { count++ }
  656. X    !/^@@\^/ && count > 0 && count <= - '$VERSION'
  657. X    END { print "$d"; print "w", "'$OUTPUT'" }
  658. X' | ed - /tmp/get.a$$
  659. Xrm -f /tmp/get.[ab]$$
  660. END_OF_FILE
  661.   if test 1511 -ne `wc -c <'get'`; then
  662.     echo shar: \"'get'\" unpacked with wrong size!
  663.   fi
  664.   # end of 'get'
  665. fi
  666. if test -f 'lastver' -a "${1}" != "-c" ; then 
  667.   echo shar: Will not clobber existing file \"'lastver'\"
  668. else
  669.   echo shar: Extracting \"'lastver'\" \(286 characters\)
  670.   sed "s/^X//" >'lastver' <<'END_OF_FILE'
  671. X#!/bin/sh
  672. X# GAPS version 4.0
  673. X# get and put system - by Nadav Har'El
  674. X# lastver: find the name of the last version in history
  675. Xcase $# in
  676. X1)     case $1 in 
  677. X    *.H)    HIST=$1;;
  678. X    *)    HIST=$1.H
  679. X    esac
  680. X    awk -F\^ '/^@@\^/ {print $2; exit}' <$HIST;;
  681. X*)     echo 'Usage: lastver file' 1>&2; exit 1 ;;
  682. Xesac 
  683. END_OF_FILE
  684.   if test 286 -ne `wc -c <'lastver'`; then
  685.     echo shar: \"'lastver'\" unpacked with wrong size!
  686.   fi
  687.   # end of 'lastver'
  688. fi
  689. if test -f 'put' -a "${1}" != "-c" ; then 
  690.   echo shar: Will not clobber existing file \"'put'\"
  691. else
  692.   echo shar: Extracting \"'put'\" \(1769 characters\)
  693.   sed "s/^X//" >'put' <<'END_OF_FILE'
  694. X#!/bin/sh
  695. X# GAPS version 4.0
  696. X# get and put system - by Nadav Har'El
  697. X# put: install file into history
  698. Xtrap 'chmod -w $HIST' 1 2 3 15
  699. Xcase $# in
  700. X1)     case $1 in 
  701. X    *.H)    HIST=$1
  702. X        set "`expr $HIST : '\(.*\)\.H'`";;
  703. X    *)    HIST=$1.H
  704. X    esac
  705. X    if test -f $HIST
  706. X    then
  707. X        chmod u+w $HIST
  708. X    fi ;;
  709. X*)     echo 'Usage: put file' 1>&2; exit 1 ;;
  710. Xesac 
  711. Xif test ! -r $1 -o ! -f $1
  712. Xthen
  713. X    echo "Put: can't open $1 for input" 1>&2
  714. X    exit 1
  715. Xfi
  716. Xif grep "^@@\^" $1 >/dev/null
  717. Xthen
  718. X    echo "file contains '@@^' in begining of line. can't save it." 1>&2
  719. X    exit 1
  720. Xfi
  721. Xtrap 'rm -f /tmp/put.[ab]$$;chmod -w $HIST 2>/dev/null; exit 1' 1 2 3 15
  722. Xif test -r $HIST
  723. Xthen
  724. X    echo "Last version of $HIST is \
  725. X`awk -F\^ '/^@@\^/ {print $2; exit}' <$HIST`"
  726. Xfi
  727. X
  728. Xwhile :
  729. Xdo
  730. X    echo -n 'Version: '
  731. X    read Version
  732. X    case $Version in
  733. X    "")    echo "Put: NULL version not allowed." 1>&2;;
  734. X    *\^*)    echo "Put: '^' character not allowed in version." 1>&2;;
  735. X    *)    break;;
  736. X    esac
  737. Xdone
  738. X
  739. Xwhile :
  740. Xdo
  741. X    echo -n 'Summary: '
  742. X    read Summary
  743. X    case $Summary in
  744. X    *\^@@\^*)
  745. X        echo "Put: The string ^@@^ must not appear in the Summary" 1>&2;;
  746. X    *)
  747. X        break;
  748. X    esac
  749. Xdone
  750. Xcase $LOGNAME in
  751. X"")    LOGNAME=`logname 2>/dev/null || getuid 2>/dev/null`
  752. X    case $LOGNAME in
  753. X    *\^*)    LOGNAME='?';;
  754. X    esac;;
  755. X*\^*)    LOGNAME='?';;
  756. Xesac
  757. X
  758. Xif get -o /tmp/put.a$$ $1                # previous versions
  759. Xthen                            # merge pieces
  760. X    cp $1 /tmp/put.b$$                # current version
  761. X    chmod +w /tmp/put.b$$
  762. X    echo "@@^$Version^$LOGNAME^`date`^$Summary" >> /tmp/put.b$$
  763. X    diff -e $1 /tmp/put.a$$ >> /tmp/put.b$$        # latest diffs
  764. X    sed -n '/^@@\^/,$p' <$HIST >>/tmp/put.b$$    # old diffs
  765. X    trap '' 1 2 3 15
  766. X    cp /tmp/put.b$$ $HIST                # put it back
  767. Xelse                            # make a new one
  768. X    echo "put: creating $HIST"
  769. X    cp $1 $HIST
  770. X    chmod =rw $HIST
  771. X    echo "@@^$Version^$LOGNAME^`date`^$Summary" >> $HIST
  772. Xfi
  773. Xrm -f /tmp/put.*$$
  774. Xchmod -w $HIST
  775. END_OF_FILE
  776.   if test 1769 -ne `wc -c <'put'`; then
  777.     echo shar: \"'put'\" unpacked with wrong size!
  778.   fi
  779.   # end of 'put'
  780. fi
  781. if test -f 'unput' -a "${1}" != "-c" ; then 
  782.   echo shar: Will not clobber existing file \"'unput'\"
  783. else
  784.   echo shar: Extracting \"'unput'\" \(991 characters\)
  785.   sed "s/^X//" >'unput' <<'END_OF_FILE'
  786. X#!/bin/sh
  787. X# GAPS version 4.0
  788. X# get and put system - by Nadav Har'El
  789. X# unput: unput the last version from history
  790. Xtrap 'chmod -w $HIST' 1 2 3 15
  791. Xcase $# in
  792. X1)     case $1 in 
  793. X    *.H)    HIST=$1;;
  794. X    *)    HIST=$1.H
  795. X    esac
  796. X    if test -f $HIST
  797. X    then
  798. X        chmod u+w $HIST
  799. X    fi ;;
  800. X*)     echo 'Usage: unput file' 1>&2; exit 1 ;;
  801. Xesac 
  802. Xif test ! -r $HIST -o ! -f $HIST
  803. Xthen
  804. X    echo "unput: can't open history file $HIST" 1>&2
  805. X    exit 1
  806. Xfi
  807. Xif test `grep "^@@\^" $HIST 2>/dev/null | wc -l` -le 1
  808. Xthen
  809. X    echo "$HIST has only one version or not an history file." 1>&2
  810. X    echo "Unput failed." 1>&2
  811. X    exit 1
  812. Xfi
  813. Xtrap 'rm -f /tmp/unput.[abc]$$;chmod -w $HIST 2>/dev/null; exit 1' 1 2 3 15
  814. Xget -1 -o /tmp/unput.a$$ $HIST             # get previous version
  815. Xawk -F\^ <$HIST >/tmp/unput.b$$ '        # find all diffs but last
  816. X    /^@@\^/ { count++
  817. X         if(count==1)print "removed version", $2 >"/tmp/unput.c'$$'" }
  818. X    count >= 2
  819. X'
  820. Xtrap '' 1 2 3 15                    # ignore signals
  821. Xcat /tmp/unput.[ab]$$ >$HIST
  822. Xcat /tmp/unput.c$$ 1>&2
  823. Xrm -f /tmp/unput.[abc]$$
  824. Xchmod -w $HIST
  825. END_OF_FILE
  826.   if test 991 -ne `wc -c <'unput'`; then
  827.     echo shar: \"'unput'\" unpacked with wrong size!
  828.   fi
  829.   # end of 'unput'
  830. fi
  831. if test -f 'vcat' -a "${1}" != "-c" ; then 
  832.   echo shar: Will not clobber existing file \"'vcat'\"
  833. else
  834.   echo shar: Extracting \"'vcat'\" \(1464 characters\)
  835.   sed "s/^X//" >'vcat' <<'END_OF_FILE'
  836. X#!/bin/sh
  837. X# GAPS version 4.0
  838. X# get and put system - by Nadav Har'El
  839. X# vcat: look at one version
  840. X
  841. XVERSION=0    # current version
  842. XUSAGE="Usage: $0 [-<number version> or -v<named version> or -c] file"
  843. XINPUT=
  844. X
  845. Xwhile test "$1" != ""
  846. Xdo
  847. X    case $1 in
  848. X    -[0-9]|-[0-9][0-9]|-[0-9][0-9][0-9])
  849. X        VERSION=$1;;         # 1-999 versions
  850. X    -v*)    VERSION=$1;;
  851. X    # print current version of file (the version that
  852. X    # will be saved when calling put). useful for doing
  853. X    # vdiff -c -0 file which prints the difference between
  854. X    # file itself and the last saved version of file.
  855. X    -c)    VERSION=$1;;
  856. X    -*)    echo $USAGE 1>&2; exit 1;;
  857. X    *)    INPUT=$1
  858. X        case $INPUT in
  859. X        *.H)    ;;
  860. X        *)    INPUT=$INPUT.H ;;
  861. X        esac ;;
  862. X    esac
  863. X    shift
  864. Xdone
  865. Xcase $INPUT in
  866. X"")    echo $USAGE 1>&2; exit 1;;
  867. Xesac
  868. X
  869. Xtest -r $INPUT -a -f $INPUT || { echo "vcat: can't open $INPUT" 1>&2; exit 1; }
  870. X
  871. Xcase $VERSION in
  872. X-c)    cat  `expr $INPUT : '\(.*\).H'`
  873. X    exit 0;;
  874. X-v*)    VERSION=`ver "\`expr \"$VERSION\" : '^-v\(.*\)'\`" $INPUT` || exit 1;;
  875. Xesac
  876. X
  877. Xtrap 'rm -f /tmp/vcat.[abc]$$;exit 0' 1 2 3 15
  878. X# split into current version and editing command
  879. X#    the following doesn't work
  880. X#    sed <$INPUT -n '1,/^@@\^/w /tmp/vcat.a'$$'
  881. X#    /^@@\^/,$w /tmp/vcat.b'$$
  882. Xsed <$INPUT '/^@@\^/q' >/tmp/vcat.a$$
  883. Xsed <$INPUT -n '/^@@\^/,$w /tmp/vcat.b'$$
  884. X# preform the edits
  885. Xawk </tmp/vcat.b$$ '
  886. X    /^@@\^/ { count++ }
  887. X    !/^@@\^/ && count > 0 && count <= - '$VERSION'
  888. X    END { print "$d"; print "w", "/tmp/vcat.c'$$'" }
  889. X' | ed - /tmp/vcat.a$$
  890. Xcat /tmp/vcat.c$$
  891. Xrm -f /tmp/vcat.[abc]$$
  892. END_OF_FILE
  893.   if test 1464 -ne `wc -c <'vcat'`; then
  894.     echo shar: \"'vcat'\" unpacked with wrong size!
  895.   fi
  896.   # end of 'vcat'
  897. fi
  898. if test -f 'vdiff' -a "${1}" != "-c" ; then 
  899.   echo shar: Will not clobber existing file \"'vdiff'\"
  900. else
  901.   echo shar: Extracting \"'vdiff'\" \(558 characters\)
  902.   sed "s/^X//" >'vdiff' <<'END_OF_FILE'
  903. X#!/bin/sh
  904. X# GAPS version 4.0
  905. X# get and put system - by Nadav Har'El
  906. X# vdiff: compare two versions in history
  907. Xtrap 'rm -f /tmp/vcat[12].$$; exit 1' 1 2 3 15
  908. Xcase $# in
  909. X3)    case $3 in
  910. X    *.H)    file=$3;;
  911. X    *)    file=$3.H;;
  912. X    esac;;
  913. X1)    case $1 in
  914. X    *.H)    file=$1;;
  915. X    *)    file=$1.H;;
  916. X    esac
  917. X    set -- -0 -c;;
  918. X*)    echo "Usage: vdiff version1 version2 file" 1>&2
  919. X    rm -f /tmp/vcat[12].$$
  920. X    exit 1;;
  921. Xesac
  922. Xvcat $1 $file >/tmp/vcat1.$$ || { rm -f /tmp/vcat[12].$$;exit 1; }
  923. Xvcat $2 $file >/tmp/vcat2.$$ || { rm -f /tmp/vcat[12].$$;exit 1; }
  924. Xdiff /tmp/vcat[12].$$
  925. Xrm -f /tmp/vcat[12].$$
  926. END_OF_FILE
  927.   if test 558 -ne `wc -c <'vdiff'`; then
  928.     echo shar: \"'vdiff'\" unpacked with wrong size!
  929.   fi
  930.   # end of 'vdiff'
  931. fi
  932. if test -f 'ver' -a "${1}" != "-c" ; then 
  933.   echo shar: Will not clobber existing file \"'ver'\"
  934. else
  935.   echo shar: Extracting \"'ver'\" \(414 characters\)
  936.   sed "s/^X//" >'ver' <<'END_OF_FILE'
  937. X#!/bin/sh
  938. X# GAPS version 4.0
  939. X# get and put system - by Nadav Har'El
  940. X# ver: used in gaps programs for -v<named version> option
  941. Xcase $2 in
  942. X*.H)    file=$2;;
  943. X*)    file=$2.H;;
  944. Xesac
  945. Xif test ! -r $file
  946. Xthen
  947. X    echo "Can't open $file" 1>&2
  948. X    exit 1
  949. Xfi
  950. Xi=`grep "^@@\^" $file 2>/dev/null |
  951. Xawk '{print NR-1 "^" $0}' | fgrep "^@@^$1^" | awk -F\^ '{print $1}'`
  952. Xcase $i in
  953. X"")    echo "No Version $1" 1>&2
  954. X    exit 1;;
  955. X*)    echo -"$i";;
  956. Xesac
  957. END_OF_FILE
  958.   if test 414 -ne `wc -c <'ver'`; then
  959.     echo shar: \"'ver'\" unpacked with wrong size!
  960.   fi
  961.   # end of 'ver'
  962. fi
  963. if test -f 'vls' -a "${1}" != "-c" ; then 
  964.   echo shar: Will not clobber existing file \"'vls'\"
  965. else
  966.   echo shar: Extracting \"'vls'\" \(986 characters\)
  967.   sed "s/^X//" >'vls' <<'END_OF_FILE'
  968. X#!/bin/sh
  969. X# GAPS version 4.0
  970. X# get and put system - by Nadav Har'El
  971. X# vls: list versions in history
  972. X
  973. XVERSION=-    # the version to stop on (- if to show all versions)
  974. XXVERSION=
  975. X
  976. Xfor i
  977. Xdo
  978. X    case $i in
  979. X    -[0-9]|-[0-9][0-9]|-[0-9][0-9][0-9])
  980. X        XVERSION=; VERSION=$i; continue;;     # 1-999 versions
  981. X    -a)    XVERSION=; VERSION=-; continue;;
  982. X    -v*)    XVERSION=$i; continue;;
  983. X    *.H)    ;;
  984. X    *)    i=$i.H;;
  985. X    esac
  986. X    if test -r $i
  987. X    then
  988. X        # for each file we recalculate the numeric version from the
  989. X        # named version
  990. X        case $XVERSION in
  991. X        -v*)    VERSION=`ver "\`expr \"$XVERSION\" : '^-v\(.*\)'\`" $i` || continue;;
  992. X        esac
  993. X
  994. X        echo
  995. X        echo "    $i:"
  996. X        echo
  997. X        if test x$VERSION = x-
  998. X        then
  999. X            grep "^@@\^" $i
  1000. X        else
  1001. X            grep "^@@\^" $i | awk "{ print; if(NR>(-($VERSION))) exit }"
  1002. X        fi |
  1003. X        awk -F\^ '
  1004. X        { printf "(-%d) Version: %s, Owner: %s, ",NR-1,$2,$3
  1005. X          printf "Date: %s",$4
  1006. X          printf "\nSummary: %s", $5
  1007. X          for(i=6;i<=NF;i++)
  1008. X            printf "\n         %s",$i
  1009. X          print "\n"
  1010. X        }'
  1011. X    else
  1012. X        echo "can't open $i" 1>&2
  1013. X    fi
  1014. Xdone
  1015. END_OF_FILE
  1016.   if test 986 -ne `wc -c <'vls'`; then
  1017.     echo shar: \"'vls'\" unpacked with wrong size!
  1018.   fi
  1019.   # end of 'vls'
  1020. fi
  1021. echo shar: End of archive 1 \(of 1\).
  1022. cp /dev/null ark1isdone
  1023. MISSING=""
  1024. for I in 1 ; do
  1025.     if test ! -f ark${I}isdone ; then
  1026.     MISSING="${MISSING} ${I}"
  1027.     fi
  1028. done
  1029. if test "${MISSING}" = "" ; then
  1030.     echo You have the archive.
  1031.     rm -f ark[1-9]isdone
  1032. else
  1033.     echo You still must unpack the following archives:
  1034.     echo "        " ${MISSING}
  1035. fi
  1036. exit 0
  1037. exit 0 # Just in case...
  1038.