I've already mentioned these in threads elsewhere on these forums, I think, but since we have a new thread just for Bash documentation and tutorials, here they are:

The canonical source of info on Bash scripting is the Bash Reference Manual . In the Linux world, a decent Bash scripting tutorial is the Advanced Bash Scripting Guide. This is not actually "advanced", in that it starts from basics, so scripting newcomers should not be put off by its title. It's first paragraph reads:

Quote:

This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction . . . all the while sneaking in little snippets of UNIX® wisdom and lore. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.

It does:
- Open itself in a coloured rxvt when clicked in ROX.
- inputs words
- inputs numbers only
- has a kind of "main-menu".
- runs a external program that is not so easy to use, the commandline-calculator "bc".

"bc" can do floatingpoint-calculations, while the internal bash-calculations are limited to integer.

This program is not "better" than bc, in fact it is "stupid",as it just allows to add 2 numbers.
But it is not inteded to be a good calculator, but just to be a demo how you can realize the points mentioned above.

BASH is the default command line shell in current Puppy, at least when you are within Xwin -- and future Puppy is said to be all bash all the time, ash will be deprecated...

Many thanks to MU for his efforts in educating us about scripting.

This is my understanding which needs further clarification:

Puppy uses Ash and Busybox and the full Bash commands where these are required for a more complete implementation.
Bash is a (large) collection of C commands that can be called from the command line. Many of these commands are with their most used functions linked in one C program - Busybox. Thus Ash is a smaller, simplified Bash.

As far as I am aware the intention at one point was to move to the full Bash commands BUT it was considered wasteful of space resources and so this has not been implemented.

Puppy uses Ash and Busybox and the full Bash commands where these are required for a more complete implementation.
Bash is a (large) collection of C commands that can be called from the command line. Many of these commands are with their most used functions linked in one C program - Busybox. Thus Ash is a smaller, simplified Bash.

Well, Bash is just the shell itself. Not the collection of executables the shell can run if you ask it to. The only commands that are part of bash are the "built in" ones. In the MSDOS world these would be the "internal commands". Type the word "help" at a bash shell prompt to see its list of these. You can add aliases and shell functions to these, and they will also run "inside" Bash itself.

All other commands you can execute from Bash (or any other shell, in general) by typing their name are scripts or executable programs that are on disk somewhere and in a directory in your $PATH . In the MSDOS world they are "external commands" Some of those (many of the normal Unix commands) are written in C, but others are not.

Quote:

As far as I am aware the intention at one point was to move to the full Bash commands BUT it was considered wasteful of space resources and so this has not been implemented.

Since the Bash shell is in Puppy, the full set of (internal) Bash commands is there now. As for replacing all BusyBox commands with their individual "normal Linux" equivalents, that could be wasteful of disk space for small systems. What seems to be happening is more that as a particular Busybox command is found to lack some option or feature that Puppy needs, the "real" equivalent command is added to Puppy instead of the "cut down" Busybox version.

Oh, and strictly speaking, ash is the Almquist shell, which is not a cut-down bash, but rather a free implementation of a shell that tries to be as close as possible to the original Bourne shell. Most Linuxes, I think including Puppy, use a version of ash derived from the NetBSD /bin/sh codebase. In general, coding shell scripts for ash will ensure wide compatibility across multiple Unix and Unix-like systems, coding for Bash is more pleasant (you have more language features!), but often not quite as portable. If you do write a script that uses Bash features, be sure to put #!/bin/bash at the top of it, so that it will work on systems where Bash is installed but /bin/sh is ash or a commercial Bourne shell.

Maybe you could read http://www.tldp.org/LDP/abs/html/ first, the other document I linked to in my 10 Jan 2006 post in this thread. It may not quite have pictures, but it does have plenty of examples. The Bash Reference Manual really is just that... use it to refer to, when you need to do something you are pretty sure Bash can do, but you need the details on how. Use the LDP tutorial to learn the basics (OK, maybe a bit more than just the basics) of shell scripting first. Few people enjoy reading reference manuals cover to cover!

On many Linux systems (but not Puppy for size reasons) there is also the Bash man page, which perhaps lies somewhere between the tutorial and the ref manual -- and is what I used to learn Bash scripting!

I like the "Do not start Bash scripting as root user" tip. Yes, I've had a bad time after not quoting variables and things. Not a big deal because I just re-install on the usb but it's still a pretty good tip.

The great thing about having a bunch of bash scripts around is that even if you're on a Linux system that's somewhat alien to you, that little bash script will (in most cases) still work perfectly. So, there's always a piece of home you take with you to the next distro (or Puppy).

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum