diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/CHANGES-1.0.md | 155 | ||||
-rw-r--r-- | doc/LICENSE.shunit2 | 201 | ||||
-rw-r--r-- | doc/RELEASE_NOTES-1.0.0.txt | 72 | ||||
-rw-r--r-- | doc/RELEASE_NOTES-1.0.1.txt | 72 | ||||
-rw-r--r-- | doc/RELEASE_NOTES-1.0.2.txt | 78 | ||||
-rw-r--r-- | doc/RELEASE_NOTES-1.0.3.txt | 94 | ||||
-rw-r--r-- | doc/RELEASE_NOTES-1.0.4.md | 81 | ||||
-rw-r--r-- | doc/TODO.txt | 10 | ||||
-rw-r--r-- | doc/coding_standards.txt | 118 | ||||
-rw-r--r-- | doc/contributors.txt | 5 | ||||
-rw-r--r-- | doc/rst2html.css | 292 |
11 files changed, 1178 insertions, 0 deletions
diff --git a/doc/CHANGES-1.0.md b/doc/CHANGES-1.0.md new file mode 100644 index 0000000..dee1408 --- /dev/null +++ b/doc/CHANGES-1.0.md @@ -0,0 +1,155 @@ +Changes in shFlags 1.0.x +======================== + +Changes with 1.0.4 +------------------ + +Changed from the LGPL v2.1 license to the Apache v2.0 license so that others can +include the library or make changes without needing to release the modified +source code as well. + +Moved documentation to Markdown. + +Migrated the code to GitHub as code.google.com is turning down. + +Fixed issue #10. Usage of `expr` under FreeBSD 7.2 (FreeNAS 0.7.1) and FreeBSD +8.0 that was causing many unit tests to fail. + +Fixed issue where booleans were sometimes mis-configured to require additional +values like other flags. + +Changed `_flags_fatal()` to exit with `FLAGS_ERROR` immediately. + +Fixed issue #11. When help is requested, the help flag is no longer prefixed +with [no]. + +Upgraded shUnit2 to 2.1.6. + +Fixed issue #12. Requesting help shouldn't be considered an error. + +Added the ability to override the use of the OS default `getopt` command by +defining the `FLAGS_GETOPT_CMD` variable. + +Updated `gen_test_results.sh` and versions from shUnit2 source. + +Fixed issues# 13, 14. Added support for dashes ('-') in long flag names. The +defined flag will still be declared with underscores ('_') due to shell +limitations, so only one of a dashed flag name or an underscored flag name are +allowed, not both. + +Issue #20. Updated LGPL v2.1 license from +http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. + +Issue #15. Use `gexpr` instead of `expr` on BSD variants. + +Minor tweaks to make run on FreeBSD 9.1. + +Fixed issue in `shflags_test_public.sh` where screens >80 columns were causing a +test to fail. + +Issue #22. Fixed broken testGetFlagInfo() test. + +Created alternate `validFloat()` and `validInt()` functions that use shell +built-ins where possible to increase performance and reduce the usage of the +`expr` command. + +Added separate built-in and `expr` functions for doing math. + + +Changes with 1.0.3 +------------------ + +MAJOR CHANGE! `FLAGS_ARGC` is now obsolete, and is replaced by +`FLAGS_ARGV`. See below for more info. + +Fixed issue# 7 where long flags defined with '=' (e.g. `--abc=123`) made it +impossible for the user to know how many non-flag command-line arguments were +available because the value returned by `FLAGS_ARGC` was wrong. The +`FLAGS_ARGC` value is now obsolete, but will be maintained for backwards +compatibility. The new method of getting the non-flag arguments is by executing +`eval set -- "${FLAGS_ARGV}"` after the `FLAGS` call. The arguments will +then be available using the standard shell $#, $@, $*, $1, etc. variables. + +Due to above fix for issue# 7, there is now proper support for mixing flags +with non-flag arguments on the command-line. Previously, all non-flag arguments +had to be at the end of the command-line. + +Renamed `_flags_standardGetopt()` and `_flags_enhancedGetopt()` functions to +`_flags_getoptStandard()` and `_flags_getoptEnhanced()`. + +Took out the setting and restoration of the '-u' shell flag to treat unset +variables as an error. No point in having it in this library as it is verified +in the unit tests, and provides basically no benefit. + +Fixed bug under Solaris where the generated help was adding extra 'x' +characters. + +Added checks for reserved flag variables (e.g. `FLAGS_TRUE`). + +Fixed some unset variable bugs. + +Now report the actual `getopt` error if there is one. + +All tests now properly enable skipping based on whether a standard or enhanced +`getopt` is found. + +Added the OS version to OS release for Solaris. + +Fixed `flags_reset()` so it unsets the default value environment vars. + + +Changes with 1.0.2 +------------------ + +FLAGS_PARENT no longer transforms into a constant so that it can be defined at +run time in scripts. + +Added warning about short flags being unsupported when there are problems +parsing the options with `getopt`. + +Add default values to end of description strings. + +Fixed bug that returned an error instead of success when recalling the default +values for empty strings. + +Added warning when a duplicate flag definition is attempted. + +Improved `assert[Warn|Error]Msg()` test helper grepping. + +Replaced shell_versions.sh with a new versions library and created +`gen_test_results.sh` to make releases easier. + +Copied the coding standards from shUnit2, but haven't fully implemented them +in shFlags yet. + +Issue# 1: When a user defines their own `--help` flag, no more warning is thrown +when `FLAGS()` is called stating that the help flag already defined. + +Issue# 2: Passing the `--nohelp` option no longer gives help output. + +Issue# 3: Added support for screen width detection. + + +Changes with 1.0.1 +------------------ + +Fixed bug where the help output added '[no]' to all flag names + +Added additional example files that are referenced by the documentation. + +Improved `zsh` version and option checking. + +Upgraded shUnit2 to 2.1.4 + +Added unit testing for the help output. + +When including a library (e.g. shflags) in a script, zsh 3.0.8 doesn't actually +execute the code in-line, but later. As such, variables that are defined in the +library cannot be used until functions are called from the main code. This +required the 'help' flag definition to be moved inside the FLAGS command. + + +Changes with 1.0.0 +------------------ + +This is the first official release, so everything is new. diff --git a/doc/LICENSE.shunit2 b/doc/LICENSE.shunit2 new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/doc/LICENSE.shunit2 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/doc/RELEASE_NOTES-1.0.0.txt b/doc/RELEASE_NOTES-1.0.0.txt new file mode 100644 index 0000000..e489cf5 --- /dev/null +++ b/doc/RELEASE_NOTES-1.0.0.txt @@ -0,0 +1,72 @@ +------------------------------ +shFlags.sh 1.0.0 Release Notes +------------------------------ + +Preface +------- +Copyright 2008 Kate Ward. All Rights Reserved. +Released under the LGPL (GNU Lesser General Public License) + +Author: Kate Ward (kate.ward@forestent.com) + +This document covers any known issues and workarounds for the stated release of +shFlags. + +General info +------------ + +This is the first official release of shFlags. The project is modeled after the +gflags code released by Google on http://code.google.com/p/google-gflags/. Many +thanks for the code they have provided. + +As this is the first release, there are bound to be issues. Feel free + +Disclamer +--------- + +The unit tests +-------------- + +shFlags is designed to work on as many environments as possible, but not all +environments are created equal. As such, not all of the unit tests will succeed +on every platform. The unit tests are therefore designed to fail, indicating to +the tester that the supported functionality is not present, but an additional +test is present to verify that shFlags properly caught the limitation and +presented the user with an appropriate error message. + +shFlags tries to support both the standard and enhanced versions of ``getopt``. +As each responds differently, and not everything is supported on the standard +version, some unit tests will be skipped (i.e. ASSERTS will not be thrown) when +the standard version of ``getopt`` is detected. The reason being that there is +no point testing for functionality that is positively known not to exist. A +tally of skipped tests will be kept for later reference. + +Standard vs Enhanced getopt +--------------------------- + +Here is a matrix of the supported features of the various getopt variants. + ++-------------------------+---+---+ +|Feature |std|enh| ++=========================+===+===+ +|short option names | Y | Y | +|long option names | N | Y | +|spaces in string options | N | Y | ++-------------------------+---+---+ + +Known Issues +------------ + +The getopt version provided by default with all versions of Solaris (up to and +including Solaris 10) is the standard version. As such, only short flags are +supported. + +The getopt version provided by default with all versions of Mac OS X (up to and +including 10.5) is the standard version. As such, only short flags are +supported. + +Workarounds +----------- + +The zsh shell requires the 'shwordsplit' option to be set, and the special +FLAGS_PARENT variable must be defined. diff --git a/doc/RELEASE_NOTES-1.0.1.txt b/doc/RELEASE_NOTES-1.0.1.txt new file mode 100644 index 0000000..651e204 --- /dev/null +++ b/doc/RELEASE_NOTES-1.0.1.txt @@ -0,0 +1,72 @@ +------------------------------ +shFlags.sh 1.0.1 Release Notes +------------------------------ + +Preface +------- +Copyright 2008 Kate Ward. All Rights Reserved. +Released under the LGPL (GNU Lesser General Public License) + +Author: Kate Ward (kate.ward@forestent.com) + +This document covers any known issues and workarounds for the stated release of +shFlags. + +General info +------------ + +This is a minor bugfix release of shFlags. It mainly fixes poor output of the +automated help system, but it also includes a couple more examples that are +referenced by the documentation. + +Please see the CHANGES-1.0.txt file for a complete list of changes. + +Disclamer +--------- + +The unit tests +-------------- + +shFlags is designed to work on as many environments as possible, but not all +environments are created equal. As such, not all of the unit tests will succeed +on every platform. The unit tests are therefore designed to fail, indicating to +the tester that the supported functionality is not present, but an additional +test is present to verify that shFlags properly caught the limitation and +presented the user with an appropriate error message. + +shFlags tries to support both the standard and enhanced versions of ``getopt``. +As each responds differently, and not everything is supported on the standard +version, some unit tests will be skipped (i.e. ASSERTS will not be thrown) when +the standard version of ``getopt`` is detected. The reason being that there is +no point testing for functionality that is positively known not to exist. A +tally of skipped tests will be kept for later reference. + +Standard vs Enhanced getopt +--------------------------- + +Here is a matrix of the supported features of the various getopt variants. + ++-------------------------+---+---+ +|Feature |std|enh| ++=========================+===+===+ +|short option names | Y | Y | +|long option names | N | Y | +|spaces in string options | N | Y | ++-------------------------+---+---+ + +Known Issues +------------ + +The getopt version provided by default with all versions of Mac OS X (up to and +including 10.5) is the standard version. As such, only short flags are +supported. + +The getopt version provided by default with all versions of Solaris (up to and +including Solaris 10) is the standard version. As such, only short flags are +supported. + +Workarounds +----------- + +The zsh shell requires the 'shwordsplit' option to be set, and the special +FLAGS_PARENT variable must be defined. diff --git a/doc/RELEASE_NOTES-1.0.2.txt b/doc/RELEASE_NOTES-1.0.2.txt new file mode 100644 index 0000000..f8154c7 --- /dev/null +++ b/doc/RELEASE_NOTES-1.0.2.txt @@ -0,0 +1,78 @@ +------------------------------ +shFlags.sh 1.0.1 Release Notes +------------------------------ + +Preface +------- +Copyright 2008 Kate Ward. All Rights Reserved. +Released under the LGPL (GNU Lesser General Public License) + +Author: Kate Ward (kate.ward@forestent.com) + +This document covers any known issues and workarounds for the stated release of +shFlags. + +General info +------------ + +This is both a minor bug fix release, and a minor new feature release of +shFlags. It adds several warning messages, fixes three issues, and now displays +the default value behind the help string when help is requested. Additionally, +the coding standards have been modified slightly and officially documented. +They were taken from the standards used by shUnit2 (the unit testing framework +used for the unit testing). + +Please see the CHANGES-1.0.txt file for a complete list of changes. + +The unit tests +-------------- + +shFlags is designed to work on as many environments as possible, but not all +environments are created equal. As such, not all of the unit tests will succeed +on every platform. The unit tests are therefore designed to fail, indicating to +the tester that the supported functionality is not present, but an additional +test is present to verify that shFlags properly caught the limitation and +presented the user with an appropriate error message. + +shFlags tries to support both the standard and enhanced versions of **getopt**. +As each responds differently, and not everything is supported on the standard +version, some unit tests will be skipped (i.e. ASSERTS will not be thrown) when +the standard version of **getopt** is detected. The reason being that there is +no point testing for functionality that is positively known not to exist. A +tally of skipped tests will be kept for later reference. + +To see the test results for the various OSes tested, please visit +http://forestent.com/projects/shflags/testresults/. + +Standard vs Enhanced getopt +--------------------------- + +Here is a matrix of the supported features of the various **getopt** variants. + ++-------------------------+---+---+ +|Feature |std|enh| ++=========================+===+===+ +|short option names | Y | Y | +|long option names | N | Y | +|spaces in string options | N | Y | ++-------------------------+---+---+ + +Known Issues +------------ + +The **getopt** version provided by default with all versions of Mac OS X (up to +and including 10.5.5) is the standard version. As such, only short flags are +supported. + +The **getopt** version provided by default with all versions of Solaris (up to +and including Solaris 10 and OpenSolaris) is the standard version. As such, +only short flags are supported. + +Workarounds +----------- + +The Zsh shell requires the ``shwordsplit`` option to be set, and the special +``FLAGS_PARENT`` variable must be defined. + + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 diff --git a/doc/RELEASE_NOTES-1.0.3.txt b/doc/RELEASE_NOTES-1.0.3.txt new file mode 100644 index 0000000..edfb1e2 --- /dev/null +++ b/doc/RELEASE_NOTES-1.0.3.txt @@ -0,0 +1,94 @@ +------------------------------ +shFlags.sh 1.0.3 Release Notes +------------------------------ + +Preface +======= +Copyright 2008-2009 Kate Ward. All Rights Reserved. +Released under the LGPL (GNU Lesser General Public License) +Author: kate.ward@forestent.com (Kate Ward) + +This document covers any known issues and workarounds for the stated release of +shFlags. + +Release info +============ + +This is a major bug fix release. The biggest fix is in how non-flag arguments are +made available to the script. + +Major changes +------------- + +The use of the ``FLAGS_ARGC`` variable is now obsolete. It will be maintained +for backwards compatibility with old scripts, but its value is known to be +wrong when flag and non-flag arguments are mixed together on the command-line. + +To gain access to the non-flag arguments, replace the following snippet of code +in your scripts with the updated version. + +old :: + shift ${FLAGS_ARGC} + +new :: + eval set -- "${FLAGS_ARGV}" + +Please see the CHANGES-1.0.txt file for a complete list of changes. + +Obsolete items +-------------- + +Bug fixes +--------- + +Issue# 7 Flags set with '=' result in off-by-one shifting error + +General info +============ + +The unit tests +-------------- + +shFlags is designed to work on as many environments as possible, but not all +environments are created equal. As such, not all of the unit tests will succeed +on every platform. The unit tests are therefore designed to fail, indicating to +the tester that the supported functionality is not present, but an additional +test is present to verify that shFlags properly caught the limitation and +presented the user with an appropriate error message. + +shFlags tries to support both the standard and enhanced versions of ``getopt``. +As each responds differently, and not everything is supported on the standard +version, some unit tests will be skipped (i.e. ASSERTS will not be thrown) when +the standard version of ``getopt`` is detected. The reason being that there is +no point testing for functionality that is positively known not to exist. A +tally of skipped tests will be kept for later reference. + +Standard vs Enhanced getopt +--------------------------- + +Here is a matrix of the supported features of the various **getopt** variants. + ++=========================================+=====+=====+ +| Feature | std | enh | ++-----------------------------------------+-----+-----+ +| short option names | Y | Y | +| long option names | N | Y | +| spaces in string options | N | Y | +| intermixing of flag and non-flag values | N | Y | ++=========================================+=====+=====+ + +Known Issues +------------ + +The **getopt** version provided by default with all versions of Mac OS X (up to +and including 10.5.6) and Solaris (up to and including Solaris 10 and +OpenSolaris) is the standard version. + +Workarounds +----------- + +The Zsh shell requires the ``shwordsplit`` option to be set and the special +``FLAGS_PARENT`` variable must be defined. See ``src/shflags_test_helpers`` to +see how the unit tests do this. + +.. vim:fileencoding=latin1:ft=rst:spell:tw=80 diff --git a/doc/RELEASE_NOTES-1.0.4.md b/doc/RELEASE_NOTES-1.0.4.md new file mode 100644 index 0000000..30e75a8 --- /dev/null +++ b/doc/RELEASE_NOTES-1.0.4.md @@ -0,0 +1,81 @@ +# shFlags.sh 1.0.4 Release Notes + +Preface +======= + +Copyright 2008-2009 Kate Ward. All Rights Reserved. +Released under the Apache License. +Author: kate.ward@forestent.com (Kate Ward) + +This document covers any known issues and workarounds for the stated release of +shFlags. + +Release info +============ + +This is a minor bug fix release. + +Please see the `CHANGES-1.0.txt` file for a complete list of changes. + +Major changes +------------- + +Changed from the LGPL v2.1 license to the Apache v2.0 license so that others can +include the library or make changes without needing to release the modified +source code as well. + +Obsolete items +-------------- + +None + +Bug fixes +--------- + +Issue #10 - Changed the internal usage of the `expn` command to fix issues +under FreeBSD. + +General info +============ + +The unit tests +-------------- + +shFlags is designed to work on as many environments as possible, but not all +environments are created equal. As such, not all of the unit tests will succeed +on every platform. The unit tests are therefore designed to fail, indicating to +the tester that the supported functionality is not present, but an additional +test is present to verify that shFlags properly caught the limitation and +presented the user with an appropriate error message. + +shFlags tries to support both the standard and enhanced versions of `getopt`. +As each responds differently, and not everything is supported on the standard +version, some unit tests will be skipped (i.e. ASSERTS will not be thrown) when +the standard version of `getopt` is detected. The reason being that there is +no point testing for functionality that is positively known not to exist. A +tally of skipped tests will be kept for later reference. + +Standard vs Enhanced getopt +--------------------------- + +Here is a matrix of the supported features of the various `getopt` variants. + +| Feature | std | enh | +|-----------------------------------------|-----|-----| +| short option names | Y | Y | +| long option names | N | Y | +| spaces in string options | N | Y | +| intermixing of flag and non-flag values | N | Y | + +Known Issues +------------ + +The `getopt` version provided by default with all versions of Mac OS X (up to +and including 10.10.2) and Solaris (up to and including Solaris 10 and +OpenSolaris) is the standard version. + +Workarounds +----------- +The Zsh shell requires the `shwordsplit` option to be set and the special +`FLAGS_PARENT` variable must be defined. See `src/shflags_test_helpers` to +see how the unit tests do this. diff --git a/doc/TODO.txt b/doc/TODO.txt new file mode 100644 index 0000000..515c851 --- /dev/null +++ b/doc/TODO.txt @@ -0,0 +1,10 @@ +improve zsh, automatically ... (pulled from configure) + + if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST + else diff --git a/doc/coding_standards.txt b/doc/coding_standards.txt new file mode 100644 index 0000000..1a9b52e --- /dev/null +++ b/doc/coding_standards.txt @@ -0,0 +1,118 @@ +Coding Standards +================ + +shFlags is more than just a simple 20 line shell script. It is a pretty +significant library of shell code that at first glance is not that easy to +understand. To improve code readability and usability, some guidelines have +been set down to make the code more understandable for anyone who wants to read +or modify it. + +Function Documentation +---------------------- + +Each function should be preceded by a header that provides the following: + +#. A one-sentence summary of what the function does +#. (optional) A longer description of what the function does, and perhaps some + special information that helps convey its usage better. +#. Args: a one-line summary of each argument of the form: + ``name: type: description`` +#. Output: a one-line summary of the output provided. Only output to STDOUT + must be documented, unless the output to STDERR is of significance (i.e. not + just an error message). The output should be of the form: + ``type: description`` +#. Returns: a one-line summary of the value returned. Returns in shell are + always integers, but if the output is a true/false for success (i.e. a + boolean), it should be noted. The output should be of the form: + ``type: description`` + +Here is a sample header: :: + + # Return valid getopt options using currently defined list of long options. + # + # This function builds a proper getopt option string for short (and long) + # options, using the current list of long options for reference. + # + # Args: + # _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*) + # Output: + # string: generated option string for getopt + # Returns: + # boolean: success of operation (always returns True) + +Variable and Function Names +--------------------------- + +All shFlags specific constants, variables, and functions will be prefixed +appropriately with 'flags'. This is to distinguish usage in the shFlags code +from users own scripts so that the shell name space remains predictable to +users. The exceptions here are the standard ``assertEquals``, etc. functions. + +All non built-in constants and variables will be surrouned with squiggle +brackets, e.g. '${flags_someVariable}' to improve code readability. + +Due to some shells not supporting local variables in functions, care in the +naming and use of variables, both public and private, is very important. +Accidental overriding of the variables can occur easily if care is not taken as +all variables are technically global variables in some shells. + +================================ ======================== +**type** **sample** +global public constant ``FLAGS_TRUE`` +global private constant ``__FLAGS_SHELL_FLAGS`` +global public variable ``flags_variable`` +global private variable ``__flags_variable`` +global macro ``_FLAGS_SOME_MACRO_`` +public function ``flags_function`` +public function, local variable ``flags_variable_`` +private function ``_flags_function`` +private function, local variable ``_flags_variable_`` +================================ ======================== + +Where it makes sense to improve readability, variables can have the first +letter of the second and later words capitalized. For example, the local +variable name for the help string length is ``flags_helpStrLen_``. + +There are three special-case global public variables used. They are used due to +overcome the limitations of shell scoping or to prevent forking. The three variables are: + + - flags_error + - flags_output + - flags_return + +Local Variable Cleanup +---------------------- + +As many shells do not support local variables, no support for cleanup of +variables is present either. As such, all variables local to a function must be +cleared up with the ``unset`` command at the end of each function. + +Indentation +----------- + +Code block indentation is two (2) spaces, and tabs may not be used. :: + + if [ -z 'some string' ]; then + someFunction + fi + +Lines of code should be no longer than 80 characters unless absolutely +necessary. When lines are wrapped using the backslash character '\', subsequent +lines should be indented with four (4) spaces so as to differentiate from the +standard spacing of two characters, and tabs may not be used. :: + + for x in some set of very long set of arguments that make for a very long \ + that extends much too long for one line + do + echo ${x} + done + +When a conditional expression is written using the builtin [ command, and that +line must be wrapped, place the control || or && operators on the same line as +the expression where possible, with the list to be executed on its own line. :: + + [ -n 'some really long expression' -a -n 'some other long expr' ] && \ + echo 'that was actually true!' + +.. vim:spell +.. $Id$ diff --git a/doc/contributors.txt b/doc/contributors.txt new file mode 100644 index 0000000..2c3c824 --- /dev/null +++ b/doc/contributors.txt @@ -0,0 +1,5 @@ +I'd like to thank these people for their contributisons to shFlags. + +Maciej BliziĆski <blizinski@google.com> +Bjarni Einarsson <bre@google.com> +pvanderdoes [http://code.google.com/u/103206786526099082032/] diff --git a/doc/rst2html.css b/doc/rst2html.css new file mode 100644 index 0000000..01983a5 --- /dev/null +++ b/doc/rst2html.css @@ -0,0 +1,292 @@ +/* +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Date: $Date: 2007-04-11 11:48:16 +0100 (Wed, 11 Apr 2007) $ +:Revision: $Revision: 2791 $ +:Copyright: This stylesheet has been placed in the public domain. +:Modified by: Kate Ward <kate.ward@forestent.com> + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin-left: 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left { + clear: left } + +img.align-right { + clear: right } + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font-family: serif ; + font-size: 100% } + +pre.literal-block, pre.doctest-block { + margin-left: 2em ; + margin-right: 2em ; + background-color: #eeeeee } + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +/* +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } +*/ + +table.footnote { + border-left: solid 1px black; + margin-left: 1px ; + font-size: 80% } + } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +/* +tt.docutils { + background-color: #eeeeee } +*/ + +ul.auto-toc { + list-style-type: none } + +/* customizations by kward */ + +h1 { font-size: 133%; border-top:1px solid #CCCCFF; } +h1.title { font-size: 150%; border-top:0px; padding-top: 1em; } +/* div.document { font-size: 90% } */ |