Skip to content

jsonbash — The JSON Bourne Again shell.

License

Notifications You must be signed in to change notification settings

ChrisTollefson/jsonbash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 

Repository files navigation

jsonbash — The JSON Bourne Again Shell

matt-daemon stars in jsonbash — the JSON Bourne Again shell.

Matt Daemon in JSON Bourne Again Shell

(Image based on this.)

TOC

TODO

Installation

TODO

Linux ladies love installing matt-daemon...

finger
mount
unzip
strip
touch
more
yes yes

Usage

TODO

FAQ

So it's actually JavaScript, not JSON?

OK, you got me, it's not JSON (at least insofar as JSON isn't JavaScript).

Then why is it called JSON Bourne Again Shell?

To quote from the original projects[1][2][3]:

I'm not sure what the [jsonbash] project does yet, but I'm pretty excited about the name.

Wait — is this shell just the Node.js REPL?

Yeah.

#!/usr/bin/env node

Hasn't that been done before?

Yep.

So is JSON Bourne Again Shell basically useless?

AFAICT, yes.

Then why do this?

Idunno, for fun I guess?

But it was prompted by Apple switching the default shell from Bourne Again Shell (GNU Bash) to Z shell as of macOS Catalina (10.15).

To go off on an opinionated tangent...

This change in macOS was perhaps due to the licensing of GNU Bash: version 4 (2009) and later have been licensed under GPLv3, whereas version 3 (2004) was licensed under GPLv2. One motivation behind version 3 of the GPL was to restrict Tivoization, whereby vendors of hardware (e.g. TiVo) would incorporate copyleft-licensed open-source software into their products, but use hardware restriction (such as digital signatures) to prevent modified versions of that software from running on those products — arguably defeating the copyleft purpose of the license as far as that hardware is concerned. Even though GNU Bash is already at version 5 (2019), macOS still ships with version 3.2.57 (2007), which was the last version of GNU Bash licensed under GPLv2. So maybe Apple is gearing up to implement some kind of Tivoization for their own hardware products? To do so, they couldn't include any GPLv3 code in macOS, which might explain why GNU Bash is stuck at 3.2.57.

But according to http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/, Apple has been removing specifically GPL-licensed software packages as of Mac OS X Leopard (10.5) (or earlier?):

macOS version Number of GPL-licensed packages
10.5 — Leopard 47
10.6 — Snow Leopard 44
10.7 — Lion 29
10.8 — Mountain Lion 22
10.9 — Mavericks 19
10.10 — Yosemite 18
10.11 — El Capitan 16
10.12 — Sierra 16

Maybe that's a coincidence and this is speculation, but the switch to Z shell as the default could foreshadow GNU Bash's eventual removal from macOS entirely. It's bad enough that it's already a decade out-of-date, but IMHO, the complete loss of bash would be unfortunate for developers on macOS and for interoperability between operating systems generally.


To be fair, Apple doesn't seem to be backing away from open-source; on the contrary, they appear to embrace it, for example, as stated at https://developer.apple.com/opensource/:

Open source software is at the heart of Apple platforms and developer tools, and Apple continues to contribute and release significant quantities of open source code.

And I concur, based on some of the open-source projects listed there, or previously hosted at macOS forge:

Project License
github ALAC — Apple Lossless Audio Codec Apache (2.0)
www Bonjour mDNSResponder — Zero-configuration networking Apache (2.0)
github wiki CUPS — Common UNIX Printing System Apache (2.0)
www Darwin — macOS/iOS core operating system APSL and others
github MacPorts — Package manager BSD (3-clause)
github Swift — Programming language Apache (2.0)
trac github mirror WebKit — Browser engine LGPL (2.1)
BSD (2-clause)
github mirror XNU — Darwin kernel APSL (2.0)
XQuartzgithub Display server and
github Window manager
BSD, MIT, variants
APSL (2.0)

But most of those licenses are permissive, which would permit Tivoization. I generally favour permissive licenses, and I don't have a problem with Tivoization per se — in other words, if I don't like that a particular hardware is restricted to a particular software, then I simply won't buy that hardware. But when it comes to personal computers (and maybe even smartphones), one of my expectations is the freedom to choose what software I use on that computer. In other words, for a general purpose computer with a given CPU architecture, I should be free to run any operating system I choose (for which I have obtained a valid license) that can be built for that architecture. (Assuming, of course, availability of device drivers for that operating system.) So if Tivoization is in the future for Macs, it would be a real disappointment to me.

...But I digress.

So if we have to switch to a different shell anyway, then why not try one in JavaScript, especially with its growing popularity for application development, not to mention its ubiquitous use on the Web?

Fortunately, Matt Daemon (April 2012) has already been developed. This is not to be confused with later Matt Daemons, such as:

  • github pypi mattd.core — Matt Daemon (August 2012):
    • A voice-to-text driven plugin system in Python.
  • github mattd — Matt Daemon (2013):
    • Forked from mattd.core.
    • $ service mattd status

      Matt Daemon is running.

      $ service mattd stop

      You can't stop Matt Daemon. Permission denied. [FAILED]

  • github npm matt-daemon (2017):
    • A Node.js HTTP daemon for serving static files from a directory.
    • With Matt Daemon, there are no surprises. He just serves.

  • github pypi matt-daemon (2019):
    • A Python HTTP daemon for serving static files from a directory.

The original Matt Daemon was forked and developed into the Jason Bourne shell, which was itself forked and developed into the JSON Bourne shell. Unfortunately, the source code for these projects is currently published without a license, and therefore may not be used by anyone other than their respective copyright holders, as mentioned in GitHub Help:

...without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work.

This situation might be similar to that of the original Bourne shell, whose copyright may be disputed as part of Unix. This perhaps contributed to the development of the Bourne Again shell as an open-source replacement under GNU. Similarly, we have developed the JSON Bourne Again shell to provide a licensed alternative to the Jason Bourne shell and JSON Bourne shell (and Matt Daemon) via a complete re-write, so that none of the unlicensed code remains.

What about shells for other scripting/programming languages?

...Perhaps along the lines of csh/tcsh for C.

#!/usr/bin/env ____

Other things with similar names — and things related to those things — none of which are related to jsonbash:

Using shell commands in Node.js:

  • github npm www jBash: Implements some bash-like commands for use in JavaScript.
  • github wiki npm www ShellJS: Implements some bash commands for use in JavaScript.
    • github npm shx: Run ShellJS commands directly on the command line.
  • github npm www Node-PowerShell: Implements some PowerShell commands for use in JavaScript.
  • github npm node-cmd: Execute any existing shell commands in JavaScript.

Interactive shells:

  • github wiki npm Cash: Implements some bash commands in an interactive shell running on Node.js. The commands can also be used in JavaScript scripts. (Implemented using Vorpal.)

  • github npm jssh — JavaScript Shell: An interactive JavaScript shell that runs on Node.js. Also supports bash commands via ShellJS.

  • github www jsbash: A bash interpreter, implemented in JavaScript.

Node.js tools for building interactive CLI apps:

  • github npm Chalk: Shell text styling.

  • github npm minimist: Parses command line arguments and options.

  • github wiki npm www yargs: Parses command line arguments and options; also provides a help system and command completion. ☠

  • github wiki npm commander.js: Enables you to define the arguments and JavaScript code for a CLI command; when the command is run, commander.js parses the arguments and executes the code.

  • github wiki npm Inquirer.js: Provides an interactive CLI by enabling you to implement prompts to the user.

  • github wiki npm www Vorpal: Based on commander.js, it uses chalk for styling, minimist for argument parsing, Inquirer.js for interactive prompts, and implements its own help system and command completion to provide a complete interactive CLI app package (e.g. Cash). 🗡️

JSON tools:

  • github JSON.sh: Parses JSON in POSIX shells.

  • github json-bash — JSON for Bash: Processes JSON data in bash.

  • github npm JSON.sh: Parses JSON in various Unix shells based on the Bourne shell (ash, bash, dash and zsh).

  • github www jsonsh.com — JSON Syntax Highlight & Format: Online formatting and syntax-highlighting of JSON data (copied-and-pasted, or directly from a web-service URL).

Other tools/info:

Node.js:

  • github npm www node — Node.js.
  • github wiki npm www npm — Node Package Manager.
  • github npm www yarn — Node.js package manager (using npm repository) from Facebook.
  • github wiki npm n — Node.js version manager.
  • github nvm — Node Version Manager.
  • github nvs — Node Version Switcher.

Browser/JavaScript engines:

Credits

License

Licensed under the MIT License. See LICENSE.md.

Copyright © 2020 jsonbash authors and contributors.

About

jsonbash — The JSON Bourne Again shell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published