curious-git icon indicating copy to clipboard operation
curious-git copied to clipboard

Replace 'echo ... > file; shasum file' by herestring

Open anntzer opened this issue 2 years ago • 0 comments

Consider the following snippet

$ # Make a file with a single line of text
$ echo "git is a rude word in UK English" > git_is_rude
$ # Show the SHA1 hash
$ shasum git_is_rude
30ad6c360a692c1fe66335bb00d00e0528346be5  git_is_rude

in the "curious tale". I was looking at the suitability of the (really nice :-)) tale for people who have no knowledge of shell scripting at all (e.g., coming from Windows) and thought that you may as well get rid of echo (and replace the redirection by a herestring, which is not much more complex):

$ # Show the SHA1 hash of the sentence below
$ shasum <<<'git is a rude word in UK English'
30ad6c360a692c1fe66335bb00d00e0528346be5  -

(there's another similar snippet just below which could be changed in the same way).

(I can make a PR if you're happy with the change, or let you make it yourself, whatever works for you.)

anntzer avatar Apr 25 '23 17:04 anntzer