shlint 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/shlint +43 -20
  2. metadata +2 -2
data/lib/shlint CHANGED
@@ -12,22 +12,27 @@ set -o errexit
12
12
  shlint_shells="zsh ksh bash dash sh"
13
13
 
14
14
  shlint_debug=0
15
- shlint_commands=""
15
+ shlint_checkdir=0
16
+ shlint_filelist=""
16
17
 
17
- if [ $# -eq 0 ]; then
18
- cat <<-DOC
19
- shlint - shell linting utility.
18
+ usage() {
19
+ echo \
20
+ "shlint - shell linting utility.
20
21
 
21
22
  Usage: shlint [OPTIONS] <FILE...>
22
23
 
23
- Drop me into your PATH for great justice!
24
+ if '.' (without quotes) is specified for FILE, directory is checked
25
+ recursively, ignoring hidden (dot prefixed) files and directories.
24
26
 
25
27
  Default shells tested are:
26
28
  $shlint_shells
27
29
 
28
30
  Place a .shlintrc file in your homedir to override default shells.
29
31
  This is expected to be shell syntax, specified as:
30
- shlint_shells="list installed shells here separated by spaces"
32
+ shlint_shells=\"list installed shells here separated by spaces\"
33
+
34
+ You can also set debug mode on here permanently, with:
35
+ shlint_debug=1
31
36
 
32
37
  OSX Users:
33
38
  Use brew (http://mxcl.github.com/homebrew/) to install additional
@@ -35,23 +40,38 @@ Usage: shlint [OPTIONS] <FILE...>
35
40
 
36
41
  Options:
37
42
  --debug Prints additional output.
38
- DOC
39
- exit 0
43
+ "
44
+ }
45
+
46
+ # Argument parsing
47
+ if [ $# -eq 0 ] ; then
48
+ usage ; exit 0
40
49
  fi
41
50
 
42
- for shlint_cmd in $@
43
- do
44
- if [ "--debug" = "$shlint_cmd" ]; then
45
- shlint_debug=1
46
- else
47
- shlint_commands="$shlint_commands $shlint_cmd"
48
- fi
51
+ for cmd in $@ ; do
52
+ case "$cmd" in
53
+ "--debug"|"-d") shlint_debug=1 ; shift ;;
54
+ ".") shlint_checkdir=1 ; shift ;;
55
+ "--help"|"-h") usage ; exit 0 ; shift ;;
56
+ esac
49
57
  done
50
58
 
59
+ if [ $shlint_checkdir -eq 1 ] ; then
60
+ shlint_filelist="$(grep -lr '#!/bin/sh' . | grep -v '^\.\/\.')"
61
+ else
62
+ if [ $# -eq 0 ] ; then
63
+ echo "Nothing to check."
64
+ exit 0
65
+ fi
66
+ for param in $@ ; do
67
+ shlint_filelist="$shlint_filelist $param"
68
+ done
69
+ fi
70
+
51
71
  # Override default shell tests
52
72
  # Regular shell syntax here.
53
73
  if [ -f ~/.shlintrc ]; then
54
- . ~/.shlintrc
74
+ . ~/.shlintrc || exit 1
55
75
  fi
56
76
 
57
77
  for shlint_shell in $shlint_shells
@@ -59,14 +79,17 @@ do
59
79
  if [ $shlint_debug = 1 ]; then
60
80
  echo "Using $shlint_shell..."
61
81
  fi
62
- for shlint_cmd in $shlint_commands
82
+ for shlint_file in $shlint_filelist
63
83
  do
64
84
  if [ $shlint_debug = 1 ]; then
65
- echo "Testing $shlint_cmd"
66
- $shlint_shell -n $shlint_cmd
85
+ echo "Testing $shlint_file"
86
+ $shlint_shell -n $shlint_file
67
87
  fi
68
88
  done
69
89
  done
70
90
 
91
+ if [ $shlint_debug = 1 ] ; then
92
+ echo "Checking for bashisms..."
93
+ fi
71
94
  # Check for bashisms
72
- checkbashisms $shlint_commands
95
+ checkbashisms $shlint_filelist
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2012-12-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Checks the syntax of your shellscript against known and available shells.
15
15
  email: