Hot answers tagged ash
25
There's checkbashisms. On Debian, it's shipped as part of the package maintainer tools.
Test your scripts under dash and posh. Both have a few non-POSIX constructs, but if your script works in both, it's likely to work in most places. (With the caveat that it's difficult to test typical shell scripts as they tend to have a lot of corner cases.)
If you ...
7
The short answer is no, they're not 100% compatible.
But most the shells are pretty close to the basic, so you would only rarely bump into inconsistencies. In fact, most shells differ not much by added syntax, but by some extra features like tab-completion and similar.
Also, dash is sort of a descendant of ash - or port from BSD to linux, to be precise. ...
3
[TL,DR: use the urlencode_grouped_case version in the last code block.]
Awk can do most of the job, except that it annoyingly lacks a way to convert from a character to its number. If od is present on your device, you can use it to convert all characters (more precisely, bytes) into the corresponding number (written in decimal, so that awk can read it), ...
2
Perhaps GRASS GIS pre-defines a variable named "day"?
The code doesn't work in straight bash by the way. You don't actually increment the value of "day".
#!/bin/bash
for (( day=5; day<367; day=day+5 )); do
# commands that I've tested without a loop.
echo $day
done
exit 0
That works for me, bash 2.05b on a RHEL 5.0 server.
1
This error message comes from ash. There are several shells with a similar syntax. Ash is a relatively basic one designed for a small memory footprint and fast execution. Another common shell is Bash. Bash has more features. The syntax you posted exist only in bash (and some other shells, but not ash).
In ash, you would need to write¹:
day=5
while [ $day ...
Only top voted, non community-wiki answers of a minimum length are eligible