Write a shell script called shug using dash that mimics the git commands git-init, git-add and git-commit precisely. shu

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a shell script called shug using dash that mimics the git commands git-init, git-add and git-commit precisely. shu

Post by answerhappygod »

Write a shell script called shug using dash that mimics the gitcommands git-init, git-add and git-commit precisely.
shug-init: The shug-init command creates an empty shugrepository. shug-init should create a directory named .shug, whichit will use to store the repository. It should produce an errormessage if this directory already exists. You should match this,and other error messages exactly.
For example:
Write A Shell Script Called Shug Using Dash That Mimics The Git Commands Git Init Git Add And Git Commit Precisely Shu 1
Write A Shell Script Called Shug Using Dash That Mimics The Git Commands Git Init Git Add And Git Commit Precisely Shu 1 (44.3 KiB) Viewed 38 times
shug-add: The shugg-add command adds the contents of one or morefiles to the index. Files are added to the repository in a two-stepprocess. The first step is adding them to the index. You will needto store files in the index somehow in the .shug sub-directory. Forexample, you might choose store them in a sub-directory of .shug.Only ordinary files in the current directory can be added. You canassume filenames start with an alphanumeric character ([a-zA-Z0-9])and will only contain alpha-numeric characters, plus '.', '-' and'_' characters. The shug-add command, and other shug commands, willnot be given pathnames with slashes.
shug-commit: The shug-commit command saves a copy of all filesin the index to the repository. A message describing the commitmust be included as part of the commit command. shug commits arenumbered sequentially: they are not hashes, like Git. You mustmatch the numbering scheme. You can assume the commit message isASCII, does not contain new-line characters, and does not startwith a '-' character.
shug-log: The shug-log command prints a line for every commitmade to the repository: each line should contain the commit numberand the commit message.
shug-show: The shug-show should print the contents of thespecified filename as of the specified commit. If commit isomitted, the contents of the file in the index should be printed.You can assume the commit if specified will be a non-negativeinteger.
For example:
Write A Shell Script Called Shug Using Dash That Mimics The Git Commands Git Init Git Add And Git Commit Precisely Shu 2
Write A Shell Script Called Shug Using Dash That Mimics The Git Commands Git Init Git Add And Git Commit Precisely Shu 2 (103.27 KiB) Viewed 38 times
I NEED CLEAR, THOROUGH AND CORRECT ANSWERS. DO EXACTLY AS I HAVEWRITTEN, MAKE SURE TO PRINT THE ERROR MESSAGES IVE PUT IN AND MAKESURE IT IS WRITTEN IN DASH SHELL (#!/bin/dash)
$ ls -d .shrug ls: cannot access '.shrug': No such file or directory $ shrug-init2] [OLD - 20T2] Initialized empty shrug repository in .shrug $ ls -d .shrug [OLD - 20T2] .shrug $ shrug-init shrug-init: error: .shrug already exists
$ ./shrug-init Initialized empty shrug repository in shrug $ echo line 1 > a $ echo hello world >b POLI $ ./shrug-add a b $ ./shrug-commit -m 'first Committed Cas2 commit 0 $ echo line 2 >>a $/shrug-add a [OLD - 20T2] commit' [OLD - 20T2] $0 ./shrug-log 1 second commit 0 first commit $ echo line 3 >>a o/shrug-add a $ echo line 4 >>a $ ./shrug-show 0:a line 11 - 20T2] $ ./shrug-show 1:a line 1-20T2] [OLD - 20T2] $ ./shrug-commit -m 'second commit' Committed as commit 1 [OLD - 20T2] [OLD - 20T2] [OLD - 20T2] [OLD - 20T2] [OLD - 20T2]
$ echo line 3 >>a $/shrug-add a $ echo line 4 $ ./shrug-show 0:a line 1-20T2] $ ./shrug-show 1:a line 1-20T2] line 2 $/shrug-show :a 20 line 1 line 2 line 3 - 20T2] $ cat a >>a line 1-20T2] line 2 line 3 line 4 - 20T2] $ ./shrug-show 0:b hello world 2] $ ./shrug-show 1:b hello world 21
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply