Showing posts with label sh. Show all posts
Showing posts with label sh. Show all posts

Monday, November 4, 2013

ShellCheck.net, useful site for sh/bash scripters

By Vasudev Ram



Saw this via a tweet by Cameron Laird (@Phaseit):

ShellCheck.net is a web site where you can paste in your sh or bash script, and it will statically analyse and lint it.

Excerpt from the ShelllCheck.net site:

[ ShellCheck is a static analysis and linting tool for sh/bash scripts. It's mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures. ]

Apparently the tool is written in Haskell.

I tried it with the default example shown, and it seems to work, since it gave 5 errors or warnings about the code.

I then tried it again with this simple shell script:
a=1
while $a -lt 5
do
    echo $a
    a=`expr $a + 1`
done

and it found a couple of issues with it: that the backquotes are deprecated, and that expr is antiquated.

- Vasudev Ram - Dancing Bison Enterprises

Contact me



DiscountMags.com



Wednesday, July 4, 2012

Generate all Linux command man pages in one shot


Just saw this today:

Linux man-pages: list of all pages, by section

Useful. It does not include most commands (i.e. binaries), though. It mainly covers system calls and C library functions. The site says that that is the case because most commands come with their own man pages.

If you want to create your own set of man pages for Linux commands or for Unix commands, you can easily do it with this short shell script:

export MAN_DIR=some_directory_name
for dir in $CMD_DIRS
do
    cd $dir
    for cmd in `ls`
    do
        man $cmd >$MAN_DIR/$cmd.m
    done
done

where CMD_DIRS has a list such as:

"/bin /usr/bin /etc /sbin /usr/sbin" in it.

That's typically one of the first things that I used to do when using a new Unix system :)

And then you can use:

vi *.m

to read them all  ...

Or use * instead of ls in backquotes.
Posted via mobile, sorry for any formatting issues.

- Vasudev Ram
www.dancingbison.com

Monday, March 26, 2012

UNIX means YOU get to choose your tools (*)

http://newcome.wordpress.com/2012/03/06/functional-programming-and-the-death-of-the-unix-way/

See the comment by Jmp on the above post.

(*) And if no tool is _just_ right for the job at hand, UNIX facilitates writing your own (in C, sh, sed/awk/et al, or in Perl, Python, Ruby, or other languages, with great integration and interaction with the OS, the shell and the many powerful command-line tools that are an integral part of UNIX.

Want proof? Just read the book "The UNIX Programming Environment" by Kernighan and Pike, and try out many of the examples in it.