by kazinator · 4y ago · 0 comments
But then, nope:
> Windows is not anything like Linux under the hood. So to get a shell working, we have three options:
> Use a tool which provides common Linux tools which have been written to work with Windows
> Use a "virtual machine" running Linux
> Use the Windows Subsystem for Linux
What "common Linux tools which have been written to work with Windows" is referring to is installing Cygwin.
This a fairly hamfisted presentation of a subject matter that could be handled in a way that is simultaneously easier to grasp and factually correct.
First of all, your goal is to teach about a specific command interpreter language, you really want to clarify how there are multiple ones which have different syntax, and brush that whole topic aside as fast as possible.
> You can see what the version is of your shell by running:
> bash --version
Yikes. If we know we are running Bash, the way to know what version it is is:
echo $BASH_VERSION
and not to run another instance of Bash.Can this book teach something simple, like comments?
> The shell ignores any text which follows a # hash symbol.
Wrong:
$ echo 'all of # this is seen'
all of # this is seen
"this is seen" looks like an example of "any text" to me.A hash comment marker is ignored if it is not quoted and escaped so as to be part of a word. The hash is also part of certain bits of syntax:
$# (dollar hash) number of positional parameters
${variable#pat} expand the content of variable, chopping off
a leading portion which matches the pat pattern.
Example:
$ echo $TERM
xterm-256color
$ echo ${TERM#xte}
rm-256colorhttps://blog.nullspace.io/batch.html
Powershell is a new arrival, limited outside of Windows. I admit that I don't know it.
The POSIX shell also has severe problems with ambiguity, and it is not an LR-parsed language:
https://archive.fosdem.org/2018/schedule/event/code_parsing_...
Use the right tool for the job, imperfect as they may be.
It is unfortunate that awk didn't grow and supplant the shell, as for many years the BWK "One True Awk" did use straightforward lex and yacc grammars.
It’s actually based on the DOS command shell [1], which in turn was modeled after CP/M [2].
I've linked to this post/comments on the repo (issue #210), they should all get addressed but it might be a while before the online version gets sorted, I'm closing out the final chapters online, once I've done this I'll likely go back to the beginning and rewrite/edit/put in a more consistent style (more code snippets, fewer screenshots etc).
I disagree with all of them from an educational point of view.
Having said that, it helps to clarify whether the audience is technical or education oriented. The title implies a technical book, so I'm with you on the comments.
This author doesn't have a chance in a room full of newbies. You have to have your technical dope straight, and it's not enough.
$ echo foo#bar
foo#barexplorer.exe uses the "ShellApi" to do some of its things, which applications can also use, like launching a file via its associated application (ShellExecute/ShellExecuteEx).
(I personally wouldn't write a book about the shell. I would be too paralyzed by the thought that at any moment, Stéphane Chazelas might crack it open.)