[TUHS] A few comments on porting the Bourne shell

Theodore Ts'o tytso at mit.edu
Wed Jan 4 15:05:41 AEST 2023


On Tue, Jan 03, 2023 at 03:03:15PM -0800, ron minnich wrote:
> I learned a lesson: people love their shell scripting languages. Nobody
> wanted to script with Go. It made me sad, but that's how it Go-es.

Speaking as someone who has written and maintaining thousands of lines
of bash shell script to support file system testing[1] for Linux,
there's a really simple reason for it.  In order to manipulate GCE
VM's, it's just **way** easier to do it from a shell.

[1] https://thunk.org/gce-xfstests

Compare:

	gcloud compute instances create VM_NAME \
	    [--image=IMAGE | --image-family=IMAGE_FAMILY] \
	    --image-project=IMAGE_PROJECT
	    --machine-type=MACHINE_TYPE

with the equivalent in in other "real languages", per [2].  It's 53
lines of C++, 64 lines of Go code, or 100 lines in Java, or 242(!)
lines in Python.

[2] https://cloud.google.com/compute/docs/instances/create-start-instance#expandable-1

Sure, it might a few thousands lines of codes of bash script.  But it
would probably be tens of thousands of lines in Go or Python.
Furthermore, when I'm trying to experiment with how to experiment with
various GCE SDK interfaces, using gcloud and shell is way, way faster
than trying to experiment with writing go code, multiple rounds of
trying to compile the go code, fixing compile syntax errors, etc ---
versus typing a few hundreds characters of a single gcloud command
line, and adjusting CLI options untll it does what you want.

For my use case, I **really** only care about it running on Linux,
since it's being used to test Linux file system kernel code.  I have a
job I'm trying to get done, which is to write reliable ext4 file
system code.  Implementing kvm-xfstests[2], gce-xfstests[3], and
android-xfstests[4] are just a means to an end.   

[2] https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md
[3] https://github.com/tytso/xfstests-bld/blob/master/Documentation/gce-xfstests.md
[4] https://github.com/tytso/xfstests-bld/blob/master/Documentation/android-xfstests.md

My time is valuable, and I'm not getting paid to write a general file
system test framework that could potentially work on FreeBSD or
NetBSD.  If my developer velocity is faster by implementing it in
bash, that's what I'm going to do, since time spent rewriting
gce-xfstests in go or Python is time that I can't spend doing work on
the ext4 file system.

If someone wants to try to reimplementing my bash scripts in go, they
should feel free to send a patch.  :-)

						- Ted



More information about the TUHS mailing list