36.10. Shell Scripting Under Windows. Comtrol DeviceMaster Software Development Kit
Реклама
Реклама
Advanced Bash-Scripting Guide
# Double brackets
String="Double brackets supported?" echo -n "Double brackets test: " if [[ "$String" = "Double brackets supported?" ]] then
echo "PASS" else
echo "FAIL" fi
# Double brackets and regex matching
String="Regex matching supported?" echo -n "Regex matching: " if [[ "$String" =~ R.....matching* ]] then
echo "PASS" else
echo "FAIL" fi
# Arrays test_arr=$default_option # FAIL
Array=( If supports arrays will print PASS ) test_arr=${Array[5]} echo "Array test: $test_arr"
# Command Substitution csub_test ()
{
echo "PASS"
} test_csub=$default_option # FAIL test_csub=$(csub_test) echo "Command substitution test: $test_csub" echo
# Completing this script is an exercise for the reader.
# Add to the above similar tests for double parentheses,
#+ brace expansion, process substitution, etc.
exit $?
36.10. Shell Scripting Under Windows
Even users running that other OS can run UNIX-like shell scripts, and therefore benefit from many of the lessons of this book. The Cygwin package from Cygnus and the MKS utilities from Mortice Kern Associates add shell scripting capabilities to Windows.
Another alternative is UWIN, written by David Korn of AT&T, of Korn Shell fame.
In 2006, Microsoft released the Windows Powershell®, which contains limited Bash-like command-line scripting capabilities.
Chapter 36. Miscellany 543
Изтегляне
Реклама