Squashed 'vendor/git.knownelement.com/reachableceo/MarkdownResume-Pipeline/' content from commit e3ea039
git-subtree-dir: vendor/git.knownelement.com/reachableceo/MarkdownResume-Pipeline git-subtree-split: e3ea03999bd0220aea1b987a92b9003ce628038b
This commit is contained in:
commit
ba4a78f9c1
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
build-output/client-submission/*.md
|
||||||
|
build-output/client-submission/*.pdf
|
||||||
|
build-output/client-submission/*.doc
|
||||||
|
build-output/job-board/*.md
|
||||||
|
build-output/job-board/*.pdf
|
||||||
|
build-output/job-board/*.doc
|
||||||
|
build-temp/*.yml
|
||||||
|
build-temp/*.md
|
235
LICENSE
Normal file
235
LICENSE
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
MarkdownResume-Pipeline
|
||||||
|
Copyright (C) 2024 reachableceo
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# MarkdownResume-Pipeline
|
||||||
|
|
||||||
|
A set of scripts and template files for managing a markdown/json resume.
|
110
Templates/CandidateInfoSheet/CandidateInfoSheet.md
Normal file
110
Templates/CandidateInfoSheet/CandidateInfoSheet.md
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
# Charles N Wyble
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Hello,
|
||||||
|
|
||||||
|
I apologize for the form letter response.
|
||||||
|
|
||||||
|
I receive a high volume of recruiter emails every day and I've found this letter to be the most efficient way to
|
||||||
|
handle the high volume of emails and reduce back and forth emails/texts/calls.
|
||||||
|
|
||||||
|
If you have any questions/comments/concerns not covered by this document, please let me know via e-mail and I'm happy to address them!
|
||||||
|
|
||||||
|
If you ask me something answered in this document, I will not respond and will not move forward with the opportunity, so please read it in detail!
|
||||||
|
|
||||||
|
## Re: share my ID over email
|
||||||
|
|
||||||
|
I WILL NOT share my (full or redacted) photo ID over email or any other electronic written
|
||||||
|
communication. If that is "required" then I have no interest in moving forward with this opportunity.
|
||||||
|
|
||||||
|
I am happy to get on a teams/zoom/google meet etc call and show my ID.
|
||||||
|
|
||||||
|
## Re: professional references
|
||||||
|
|
||||||
|
I am happy to provide professional references once an interview with the end client/customer/hiring manager/team has been scheduled. I will NOT provide references up front. If that is "required" then I have no interest in moving forward with this opportunity.
|
||||||
|
|
||||||
|
## Re: relocation
|
||||||
|
|
||||||
|
if the role is not based in **Austin TX** or **Raleigh NC** I will need to re-locate
|
||||||
|
|
||||||
|
| Question | Answer |
|
||||||
|
|-------------------------------------------|--------|
|
||||||
|
| Am I open to relocation? | Yes |
|
||||||
|
| Am I willing to re-locate at own expense? | No |
|
||||||
|
| Am I open to up to 100% travel | Yes |
|
||||||
|
|
||||||
|
Please be aware that:
|
||||||
|
|
||||||
|
- I will **only re-locate at the employer expense**.
|
||||||
|
- I will need **two weeks of time** to re-locate.
|
||||||
|
- The net amount of the re-location benefit **MUST be at least $5,000 USD** to fully compensate me for the time/effort to re-locate.
|
||||||
|
- The full re-location benefit **must be provided prior to the confirmed start date**.
|
||||||
|
- I **will NOT** accept a reimbursement based re-location package.
|
||||||
|
- I am happy to come onsite (at client expense (paid up front)) for training/orientation etc.
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
## Rate Schedule (compensation expectations)
|
||||||
|
|
||||||
|
For **fully remote** roles only:
|
||||||
|
|
||||||
|
I am open to (at the absolute minimum): **\$50.00 per hour(w2)/\$75.00 per hour (1099/corp to corp)/ $100,000.00 annually (w2)**.
|
||||||
|
|
||||||
|
I have a strong preference for roles that are : **\$65.00 per hour(w2)/\$85.00 per hour (1099/corp to corp)/ $130,000.00 annually (w2)**.
|
||||||
|
|
||||||
|
For **on-site roles**:
|
||||||
|
|
||||||
|
I am open to (at the absolute minimum): **\$75.00 per hour(w2)/\$95.00 per hour (1099/corp to corp)/ $150,000.00 annually (w2)**.
|
||||||
|
|
||||||
|
In regards to compensation structure, I am open to:
|
||||||
|
|
||||||
|
- w2
|
||||||
|
- corp to corp (I have my own LLC)
|
||||||
|
- 1099
|
||||||
|
|
||||||
|
If you have a rate for any of the compensation options above, send them all. I will pick which one works best for my situation and the opportunity.
|
||||||
|
|
||||||
|
If it's a different rate with/without benefits, send both.
|
||||||
|
|
||||||
|
If the above is in alignment with this opportunity, please feel free to send me an RTR with the best rate you can offer.
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
## Details needed for submission
|
||||||
|
|
||||||
|
### My resume
|
||||||
|
|
||||||
|
[Download Charles resume(pdf)](https://resume.reachableceo.com/job-board/CharlesNWyble-Resume.pdf)
|
||||||
|
|
||||||
|
I am happy to discuss and make edits to the resume content specific to the opportunity if you feel
|
||||||
|
they are needed.
|
||||||
|
|
||||||
|
### Candidate details
|
||||||
|
|
||||||
|
Here are my complete candidate details for submission to the role.
|
||||||
|
|
||||||
|
| Question | Answer |
|
||||||
|
|---------------------------------------|--------------------------------------------------------------------------|
|
||||||
|
| Full name | Charles Wyble |
|
||||||
|
| E-mail address | <reachableceo@reachableceo.com> |
|
||||||
|
| Phone number | 818-280-7059 |
|
||||||
|
| Preferred form of contact | E-mail will get the fastest response |
|
||||||
|
| Work authorization | US Citizen |
|
||||||
|
| Are you employed presently? | No |
|
||||||
|
| Current location | Austin, Texas |
|
||||||
|
| Current timezone | CST |
|
||||||
|
| Timezones I can work in | PST/CST/EST |
|
||||||
|
| Availability to interview | Immediate |
|
||||||
|
| Availability to start | Immediate for remote/local, two weeks for relocation |
|
||||||
|
| Open to in-office/hybrid/remote | Yes |
|
||||||
|
| Any trips planned in next six months? | No |
|
||||||
|
| Highest Education | High School (no college/university) |
|
||||||
|
| Graduated Year | 2002 |
|
||||||
|
| Name of school | Osborne Christian School |
|
||||||
|
| Location of school | Los Angeles CA |
|
||||||
|
| Linkedin Profile | [Linkedin Profile](https://www.linkedin.com/in/charles-wyble-412007337/) |
|
||||||
|
| Github Profile | [Github Profile](https://www.github.com/ReachableCEO/) |
|
||||||
|
| Last project | Contract, ended October 2024 |
|
||||||
|
| DOB | 09/14 |
|
||||||
|
| Total IT/career experience | 22 years |
|
14
Templates/CandidateInfoSheet/CandidateInfoSheet.yml
Normal file
14
Templates/CandidateInfoSheet/CandidateInfoSheet.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
title: "Charles N Wyble Candidate Details"
|
||||||
|
titlepage: true
|
||||||
|
titlepage-logo: "D:/tsys/@ReachableCEO/ReachableCEO.png"
|
||||||
|
toc: true
|
||||||
|
toc-own-page: true
|
||||||
|
date: \today
|
||||||
|
header-left: "\\hspace{1cm}"
|
||||||
|
header-center: "\\leftmark"
|
||||||
|
header-right: "Page \\thepage"
|
||||||
|
footer-left: "Charles N Wyble"
|
||||||
|
footer-center: "Tenacity. Velocity. Focus."
|
||||||
|
footer-right: "[Source code for this file](https://github.com/ReachableCEO/ReachableCEOResume/blob/main/ancillary-support-files/CharlesNWybleCandidateInfo.md)"
|
||||||
|
urlcolor: blue
|
||||||
|
page-background: "D:/tsys/@ReachableCEO/ExternalVendorCode/pandoc-latex-template/examples/page-background/backgrounds/background1.pdf"
|
4
Templates/ContactInfo/ContactInfo-ClientSubmit.md
Normal file
4
Templates/ContactInfo/ContactInfo-ClientSubmit.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{{CandidateName}}
|
||||||
|
=====
|
||||||
|
|
||||||
|
{{CandidateOneLinerSummary}}
|
6
Templates/ContactInfo/ContactInfo-JobBoard.md
Normal file
6
Templates/ContactInfo/ContactInfo-JobBoard.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{{CandidateName}}
|
||||||
|
=====
|
||||||
|
|
||||||
|
{{CandidateOneLinerSummary}}
|
||||||
|
|
||||||
|
[ [Github Profile]({{CandidateGithub}}) ] . [ [Linkedin Profile]({{CandidateLinkedin}}) ] . [ {{CandidateEmail}} ] . [ {{CandidatePhone}} ] . [ {{CandidateLocation}} ]
|
3
Templates/JobHistoryDetails/job1.md
Normal file
3
Templates/JobHistoryDetails/job1.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- Stuff
|
||||||
|
- Things
|
||||||
|
- Amazing project!
|
3
Templates/JobHistoryDetails/job2.md
Normal file
3
Templates/JobHistoryDetails/job2.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- Stuff
|
||||||
|
- Things
|
||||||
|
- Amazing project!
|
2
Templates/SkillsAndProjects/Projects.md
Normal file
2
Templates/SkillsAndProjects/Projects.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- Cool project 1.
|
||||||
|
- cool project 2.
|
2
Templates/SkillsAndProjects/Skills.csv
Normal file
2
Templates/SkillsAndProjects/Skills.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
skill1|1 years|skill,1,details,and,stuff
|
||||||
|
skill2|2 years|skill2,2,details,and,stuff,and,things
|
|
2
Templates/WorkHistory/WorkHistory.csv
Normal file
2
Templates/WorkHistory/WorkHistory.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
job1,Title of job 1,January 1 1970 - January 6 1980
|
||||||
|
job2,Title of Job 2,January 1 1970 - January 6 1980
|
|
1
build-output/client-submission/ignore-this-dir
Normal file
1
build-output/client-submission/ignore-this-dir
Normal file
@ -0,0 +1 @@
|
|||||||
|
This directory is used by the build process. Ignore it.
|
1
build-output/ignore-this-dir
Normal file
1
build-output/ignore-this-dir
Normal file
@ -0,0 +1 @@
|
|||||||
|
Working directory for the pipeline. Don't use.
|
1
build-output/job-board/ignore-this-dir
Normal file
1
build-output/job-board/ignore-this-dir
Normal file
@ -0,0 +1 @@
|
|||||||
|
This directory is used by the build process. Ignore it.
|
1
build-temp/ignore-this-dir
Normal file
1
build-temp/ignore-this-dir
Normal file
@ -0,0 +1 @@
|
|||||||
|
Working directory for the pipeline. Don't use.
|
7
build/BuildTemplate-ClientSubmission.yml
Normal file
7
build/BuildTemplate-ClientSubmission.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
title: "{{CandidateName}} Resume"
|
||||||
|
header-left: "\\hspace{1cm}"
|
||||||
|
header-center: "\\leftmark"
|
||||||
|
header-right: "Page \\thepage"
|
||||||
|
footer-left: "{{CandidateName}}"
|
||||||
|
urlcolor: {{URLCOLOR}}
|
||||||
|
page-background: "{{PAGEBACKGROUND}}"
|
12
build/BuildTemplate-JobBoard.yml
Normal file
12
build/BuildTemplate-JobBoard.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
title: "{{CandidateName}} Resume"
|
||||||
|
titlepage: true
|
||||||
|
titlepage-logo: "{{CandidateLogo}}"
|
||||||
|
date: \today
|
||||||
|
header-left: "\\hspace{1cm}"
|
||||||
|
header-center: "\\leftmark"
|
||||||
|
header-right: "Page \\thepage"
|
||||||
|
footer-left: "{{CandidateName}}"
|
||||||
|
footer-center: "{{CandidateTagline}}"
|
||||||
|
footer-right: "[Source code for this resume]({{ResumeSourceCode}})"
|
||||||
|
urlcolor: {{URLCOLOR}}
|
||||||
|
page-background: "{{PAGEBACKGROUND}}"
|
189
build/build.sh
Normal file
189
build/build.sh
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export CandidateName="First Middle Last"
|
||||||
|
export CandidatePhone="1 123 456 7890"
|
||||||
|
export CandidateLocation="Place 1/Place 2"
|
||||||
|
export CandidateEmail="candidate@domain.com"
|
||||||
|
export CandidateOneLineSummary="Super awesome and stuff."
|
||||||
|
export CandidateLinkedin="linkedin.com"
|
||||||
|
export CandidateGithub="github.com"
|
||||||
|
export CandidateLogo=""
|
||||||
|
export CandidateTagline="Your.Tagline.Here."
|
||||||
|
export ResumeSourceCode="https://git.knownelement.com/reachableceo/MarkdownResume-Pipeline"
|
||||||
|
export URLCOLOR="blue"
|
||||||
|
export PAGEBACKGROUND="../vendor/git.knownelement.com/ExternalVendorCode/pandoc-latex-template/examples/page-background/backgrounds/background3.pdf"
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
#DO NOT CHANGE ANYTHING BELOW THIS LINE
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
#source "$(dirname "${BASH_SOURCE[0]}")/bash3boilerplate.sh"
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Setup globals
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
readonly MO_PATH="bash ../vendor/git.knownelement.com/ExternalVendorCode/mo/mo"
|
||||||
|
readonly BUILD_OUTPUT_DIR="../build-output"
|
||||||
|
readonly BUILD_TEMP_DIR="../build-temp"
|
||||||
|
readonly BUILDYAML_JOBBOARD="$BUILD_TEMP_DIR/JobBoard.yml"
|
||||||
|
readonly BUILDYAML_CLIENTSUBMISSION="$BUILD_TEMP_DIR/ClientSubmission.yml"
|
||||||
|
|
||||||
|
echo "Cleaning up from previous runs..."
|
||||||
|
|
||||||
|
JobBoardMarkdownOutputFile="$BUILD_OUTPUT_DIR/job-board/Resume.md"
|
||||||
|
JobBoardPDFOutputFile="$BUILD_OUTPUT_DIR/job-board/Resume.pdf"
|
||||||
|
JobBoardMSWordOutputFile="$BUILD_OUTPUT_DIR/job-board/Resume.doc"
|
||||||
|
|
||||||
|
ClientSubmissionMarkdownOutputFile="$BUILD_OUTPUT_DIR/client-submission/Resume.md"
|
||||||
|
ClientSubmissionPDFOutputFile="$BUILD_OUTPUT_DIR/client-submission//Resume.pdf"
|
||||||
|
ClientSubmissionMSWordOutputFile="$BUILD_OUTPUT_DIR/client-submission/Resume.doc"
|
||||||
|
|
||||||
|
rm $BUILDYAML_JOBBOARD
|
||||||
|
rm $JobBoardMarkdownOutputFile
|
||||||
|
rm $JobBoardPDFOutputFile
|
||||||
|
rm $JobBoardMSWordOutputFile
|
||||||
|
|
||||||
|
rm $BUILDYAML_CLIENTSUBMISSION
|
||||||
|
rm $ClientSubmissionMarkdownOutputFile
|
||||||
|
rm $ClientSubmissionPDFOutputFile
|
||||||
|
rm $ClientSubmissionMSWordOutputFile
|
||||||
|
|
||||||
|
# Expand variables into rendered YAML files. These will be used by pandoc to create the output artifacts
|
||||||
|
|
||||||
|
$MO_PATH ./BuildTemplate-JobBoard.yml > $BUILDYAML_JOBBOARD
|
||||||
|
$MO_PATH ./BuildTemplate-ClientSubmission.yml > $BUILDYAML_CLIENTSUBMISSION
|
||||||
|
|
||||||
|
echo "Combining markdown files into single input file for pandoc..."
|
||||||
|
|
||||||
|
# Create contact info md file
|
||||||
|
$MO_PATH ../Templates/ContactInfo/ContactInfo-JobBoard.md > $BUILD_TEMP_DIR/ContactInfo-JobBoard.md
|
||||||
|
$MO_PATH ../Templates/ContactInfo/ContactInfo-ClientSubmit.md > $BUILD_TEMP_DIR/ContactInfo-ClientSubmit.md
|
||||||
|
|
||||||
|
#Pull in contact info
|
||||||
|
cat $BUILD_TEMP_DIR/ContactInfo-JobBoard.md >> $JobBoardMarkdownOutputFile
|
||||||
|
echo " " >> $JobBoardMarkdownOutputFile
|
||||||
|
|
||||||
|
cat $BUILD_TEMP_DIR/ContactInfo-ClientSubmit.md >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo " " >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
echo "## Career Highlights" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo "## Career Highlights" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
cat ../Templates/SkillsAndProjects/Projects.md >> $JobBoardMarkdownOutputFile
|
||||||
|
echo "\pagebreak" >> $JobBoardMarkdownOutputFile
|
||||||
|
|
||||||
|
cat ../Templates/SkillsAndProjects/Projects.md >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo "\pagebreak" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
echo " " >> $JobBoardMarkdownOutputFile
|
||||||
|
echo "## Employment History" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo " " >> $JobBoardMarkdownOutputFile
|
||||||
|
|
||||||
|
echo " " >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo "## Employment History" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo " " >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
#And here we do some magic...
|
||||||
|
#Pull in :
|
||||||
|
|
||||||
|
# employer
|
||||||
|
# title
|
||||||
|
# start/end dates of employment
|
||||||
|
# long form position summary data from each position
|
||||||
|
|
||||||
|
IFS=$'\n\t'
|
||||||
|
for position in \
|
||||||
|
$(cat ../Templates/WorkHistory/WorkHistory.csv); do
|
||||||
|
|
||||||
|
COMPANY="$(echo $position|awk -F ',' '{print $1}')"
|
||||||
|
TITLE="$(echo $position|awk -F ',' '{print $2}')"
|
||||||
|
DATEOFEMPLOY="$(echo $position|awk -F ',' '{print $3}')"
|
||||||
|
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
echo "**$COMPANY | $TITLE | $DATEOFEMPLOY**" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
|
||||||
|
echo "**$COMPANY | $TITLE | $DATEOFEMPLOY**" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo " " >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
cat ../Templates/JobHistoryDetails/$COMPANY.md >> "$JobBoardMarkdownOutputFile"
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
|
||||||
|
cat ../Templates/JobHistoryDetails/$COMPANY.md >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
echo " " >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
done
|
||||||
|
|
||||||
|
#Pull in my skills and generate a beautiful table.
|
||||||
|
|
||||||
|
echo "\pagebreak" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
echo "## Skills" >> "$JobBoardMarkdownOutputFile"
|
||||||
|
echo " " >> "$JobBoardMarkdownOutputFile"
|
||||||
|
|
||||||
|
echo "\pagebreak" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo " " >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
echo "## Skills" >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
echo " " >> "$ClientSubmissionMarkdownOutputFile"
|
||||||
|
|
||||||
|
#Table heading
|
||||||
|
echo "|Skill|Experience|Skill Details|" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo "|---|---|---|" >> $JobBoardMarkdownOutputFile
|
||||||
|
|
||||||
|
echo "|Skill|Experience|Skill Details|" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
echo "|---|---|---|" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
#Table rows
|
||||||
|
IFS=$'\n\t'
|
||||||
|
for skill in \
|
||||||
|
$(cat ../Templates/SkillsAndProjects/Skills.csv); do
|
||||||
|
SKILL_NAME="$(echo $skill|awk -F '|' '{print $1}')"
|
||||||
|
SKILL_YEARS="$(echo $skill|awk -F '|' '{print $2}')"
|
||||||
|
SKILL_DETAIL="$(echo $skill|awk -F '|' '{print $3}')"
|
||||||
|
echo "|**$SKILL_NAME**|$SKILL_YEARS|$SKILL_DETAIL|" >> $JobBoardMarkdownOutputFile
|
||||||
|
echo "|**$SKILL_NAME**|$SKILL_YEARS|$SKILL_DETAIL|" >> $ClientSubmissionMarkdownOutputFile
|
||||||
|
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
echo "Generating PDF output for job board version..."
|
||||||
|
|
||||||
|
pandoc \
|
||||||
|
"$JobBoardMarkdownOutputFile" \
|
||||||
|
--template eisvogel \
|
||||||
|
--metadata-file="../build-temp/JobBoard.yml" \
|
||||||
|
--from markdown \
|
||||||
|
--to=pdf \
|
||||||
|
--output $JobBoardPDFOutputFile
|
||||||
|
|
||||||
|
echo "Generating MSWord output for job board version..."
|
||||||
|
|
||||||
|
pandoc \
|
||||||
|
"$JobBoardMarkdownOutputFile" \
|
||||||
|
--metadata-file="../build-temp/JobBoard.yml" \
|
||||||
|
--from markdown \
|
||||||
|
--to=docx \
|
||||||
|
--reference-doc=resume-docx-reference.docx \
|
||||||
|
--output $JobBoardMSWordOutputFile
|
||||||
|
|
||||||
|
echo "Generating PDF output for client submission version..."
|
||||||
|
|
||||||
|
pandoc \
|
||||||
|
"$ClientSubmissionMarkdownOutputFile" \
|
||||||
|
--template eisvogel \
|
||||||
|
--metadata-file="../build-temp/ClientSubmission.yml" \
|
||||||
|
--from markdown \
|
||||||
|
--to=pdf \
|
||||||
|
--output $ClientSubmissionPDFOutputFile
|
||||||
|
|
||||||
|
echo "Generating MSWord output for client submission version..."
|
||||||
|
|
||||||
|
pandoc \
|
||||||
|
"$ClientSubmissionMarkdownOutputFile" \
|
||||||
|
--metadata-file="../build-temp/ClientSubmission.yml" \
|
||||||
|
--from markdown \
|
||||||
|
--to=docx \
|
||||||
|
--reference-doc=resume-docx-reference.docx \
|
||||||
|
--output $ClientSubmissionMSWordOutputFile
|
BIN
build/resume-docx-reference.docx
Normal file
BIN
build/resume-docx-reference.docx
Normal file
Binary file not shown.
7
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
7
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Thanks for contributing to b3bp! As part of your PR, have you:
|
||||||
|
|
||||||
|
- [ ] Added an item in [CHANGELOG.md](https://github.com/kvz/bash3boilerplate/blob/HEAD/CHANGELOG.md) with attribution?
|
||||||
|
- [ ] Added your name to the [README.md](https://github.com/kvz/bash3boilerplate/blob/HEAD/README.md#authors)
|
||||||
|
- [ ] Linted your code? (`make test` should do the trick)
|
||||||
|
|
||||||
|
If so, great! Feel free to replace this message with a description of your work and hit submit!
|
5
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/dependabot.yml
generated
vendored
Normal file
5
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/dependabot.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
groups:
|
||||||
|
production-dependencies:
|
||||||
|
dependency-type: 'production'
|
||||||
|
development-dependencies:
|
||||||
|
dependency-type: 'development'
|
30
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/workflows/ci.yml
generated
vendored
Normal file
30
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.github/workflows/ci.yml
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: b3bp CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 18.x
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
corepack yarn
|
||||||
|
- name: Lint
|
||||||
|
env:
|
||||||
|
SHELLCHECK_SEVERITY: warning
|
||||||
|
run: |
|
||||||
|
corepack yarn lint
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
corepack yarn test
|
5
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.gitignore
generated
vendored
Normal file
5
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.gitignore
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.yarn
|
||||||
|
assets/build
|
||||||
|
env.sh
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
3
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.shellcheckrc
generated
vendored
Normal file
3
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.shellcheckrc
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
external-sources=true
|
||||||
|
shell=bash
|
||||||
|
color=always
|
8
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.vscode/bash3boilerplate.code-workspace
generated
vendored
Normal file
8
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.vscode/bash3boilerplate.code-workspace
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": ".."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.yarnrc.yml
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/.yarnrc.yml
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
nodeLinker: node-modules
|
175
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/CHANGELOG.md
generated
vendored
Normal file
175
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
Here's is a combined todo/done list. You can see what todos are planned for the upcoming release, as well as ideas that may/may not make into a release in `Ideas`.
|
||||||
|
|
||||||
|
## Ideas
|
||||||
|
|
||||||
|
Unplanned.
|
||||||
|
|
||||||
|
- [ ] Better style guide checking (#84)
|
||||||
|
|
||||||
|
## main
|
||||||
|
|
||||||
|
Released: TBA.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/2.7.2...main).
|
||||||
|
|
||||||
|
- [ ]
|
||||||
|
|
||||||
|
## 2.7.2
|
||||||
|
|
||||||
|
Released: 2023-08-29
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.1...2.7.2).
|
||||||
|
|
||||||
|
- [x] Upgrade and cleanup node dependencies
|
||||||
|
- [x] Remove lanyon-based website in favor of simple redirect to github for bash3boilerplate.sh
|
||||||
|
- [x] Make tests pass again
|
||||||
|
- [x] Make linting and style checking separate actions
|
||||||
|
- [x] Add feature to edit/update comments in ini file (#132, @rfuehrer)
|
||||||
|
- [x] Upgrade to `lanyon@0.1.16`
|
||||||
|
- [x] Capture correct error_code in err_report (#124, @eval)
|
||||||
|
- [x] Enhanced ini file handling: create new file, create new sections, handle default section, read key from given section (@rfuehrer)
|
||||||
|
|
||||||
|
## v2.4.2
|
||||||
|
|
||||||
|
Released: 2019-11-07.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.4.1...v2.4.2).
|
||||||
|
|
||||||
|
- [x] Upgrade to `lanyon@0.1.16`
|
||||||
|
- [x] Capture correct error_code in err_report (#124, @eval)
|
||||||
|
- [x] Enhanced ini file handling: create new file, create new sections, handle default section, read key from given section (@rfuehrer)
|
||||||
|
|
||||||
|
## v2.4.1
|
||||||
|
|
||||||
|
Released: 2019-11-07.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.1).
|
||||||
|
|
||||||
|
- [x] Upgrade to `lanyon@0.1.7`
|
||||||
|
- [x] Allow counting how many times an argument is used (@genesiscloud)
|
||||||
|
- [x] Fix typos in megamount (thanks @gsaponaro)
|
||||||
|
- [x] Enable color in screen or tmux (#92, @gmasse)
|
||||||
|
- [x] Change `egrep` to `grep -E` in test and lib scripts to comply with ShellCheck (#92, @gmasse)
|
||||||
|
- [x] Fix typo in FAQ (#92, @gmasse)
|
||||||
|
- [x] Fix Travis CI failure on src/templater.sh (@gmasse)
|
||||||
|
- [x] Add magic variable which contains full command invocation
|
||||||
|
- [x] More contrasted alert and emergency colors (#111 @gmeral)
|
||||||
|
- [x] Add support for repeatable arguments (@genesiscloud)
|
||||||
|
- [x] Fix remaining warnings with shellcheck v0.7.0 (#107, @genesiscloud)
|
||||||
|
|
||||||
|
## v2.4.0
|
||||||
|
|
||||||
|
Released: 2016-12-21.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.3.0...v2.4.0).
|
||||||
|
|
||||||
|
- [x] Upgrade to `lanyon@0.0.143`
|
||||||
|
|
||||||
|
## v2.3.0
|
||||||
|
|
||||||
|
Released: 2016-12-21.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.2.0...v2.3.0).
|
||||||
|
|
||||||
|
- [x] Add magic variable `__i_am_main_script` to distinguish if b3bp is being sourced or called directly (#45, @zbeekman)
|
||||||
|
- [x] Add style checks for tab characters and trailing whitespace (@zbeekman)
|
||||||
|
- [x] Add backtracing to help localize errors (#44, @zbeekman)
|
||||||
|
- [x] Additional FAQ entries (#47, suggested by @gdevenyi, implemented by @zbeekman)
|
||||||
|
- [x] Ensure that shifting over `--` doesn't throw an errexit error (#21, @zbeekman)
|
||||||
|
- [x] Add Pull Request template (#83)
|
||||||
|
|
||||||
|
## v2.2.0
|
||||||
|
|
||||||
|
Released: 2016-12-21.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.1.0...v2.2.0).
|
||||||
|
|
||||||
|
- [x] README and FAQ improvements (#66, @mstreuhofer)
|
||||||
|
- [x] Add support for sourcing b3bp (#61, @mstreuhofer)
|
||||||
|
- [x] Upgrade all Node.js dependencies for development (#78)
|
||||||
|
- [x] Switch to http://lanyon.io for static site building, add a new logo
|
||||||
|
- [x] Cleanup environment variables (#58, @mstreuhofer)
|
||||||
|
- [x] Support multi-line logs (#57, @mstreuhofer)
|
||||||
|
- [x] Run shellcheck as part of the acceptance test (#79, @mstreuhofer)
|
||||||
|
- [x] Brace all variables, used `[[` instead of `[` (#33, #76, @mstreuhofer)
|
||||||
|
- [x] Add automatic usage validation for required args (#22, #65, @mstreuhofer)
|
||||||
|
- [x] Remove all usage of eval (@mstreuhofer)
|
||||||
|
- [x] Get rid of awk, sed & egrep usage (#71, @mstreuhofer)
|
||||||
|
- [x] Fix auto-color-off code (#69, #70, @mstreuhofer)
|
||||||
|
- [x] Use shellcheck to find and fix unclean code (#68, #80, @mstreuhofer)
|
||||||
|
- [x] Allow for multiline opt description in `__usage` (#7, @mstreuhofer)
|
||||||
|
- [x] Allow `__usage` and `__helptext` to be defined before sourcing `main.sh` thus makeing b3bp behave like a library (@mstreuhofer)
|
||||||
|
- [x] Add the same License text to each script header (@mstreuhofer)
|
||||||
|
|
||||||
|
## v2.1.0
|
||||||
|
|
||||||
|
Released: 2016-11-08.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v2.0.0...v2.1.0).
|
||||||
|
|
||||||
|
- [x] Cleanup b3bp variables (adds prefixes across the board) (thanks @mstreuhofer)
|
||||||
|
- [x] Add multi-line logging support (thanks @mstreuhofer)
|
||||||
|
- [x] Mangle long-option names to allow dashes (thanks @zbeekman)
|
||||||
|
- [x] Remove OS detection altogether (#38, thx @zbeekman)
|
||||||
|
- [x] Offer the main template for download as http://bash3boilerplate.sh/main.sh
|
||||||
|
- [x] Better OS detection (#38, thx @moviuro)
|
||||||
|
- [x] Improve README copy (#34, thx galaktos)
|
||||||
|
- [x] Fix unquoted variable access within (#34 thx galaktos)
|
||||||
|
- [x] For delete-key-friendliness, bundle the commandline definition block along with its parser
|
||||||
|
- [x] Less verbose header comments
|
||||||
|
- [x] For delete-key-friendliness, don't crash on undeclared help vars
|
||||||
|
- [x] Introduce `errtrace`, which is on by default (BREAKING)
|
||||||
|
- [x] Add a configurable `helptext` that is left alone by the parses and allows you to have a richer help
|
||||||
|
- [x] Add a simple documentation website
|
||||||
|
- [x] Add best practice of using `__double_underscore_prefixed_vars` to indicate global variables that are solely controlled inside your script
|
||||||
|
- [x] Make license more permissive by not requiring distribution of the LICENSE file if the copyright & attribution comments are left intact
|
||||||
|
- [x] Respect `--no-color` by setting the `NO_COLOR` flag in `main.sh` (#25, thx @gdevenyi)
|
||||||
|
- [x] Split out changelog into separate file
|
||||||
|
- [x] Added a [FAQ](./FAQ.md) (#15, #14, thanks @rouson)
|
||||||
|
- [x] Fix Travis OSX testing (before, it would silently pass failures) (#10)
|
||||||
|
- [x] Enable dashes in long, GNU style options, as well as numbers (thanks @zbeekman)
|
||||||
|
|
||||||
|
## v2.0.0
|
||||||
|
|
||||||
|
Released: 2016-02-17.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.2.1...v2.0.0).
|
||||||
|
|
||||||
|
- [x] Add tests for `templater` and follow Library export best practices
|
||||||
|
- [x] Add tests for `ini_val` and follow Library export best practices
|
||||||
|
- [x] Add tests for `parse_url` and follow Library export best practices
|
||||||
|
- [x] Add tests for `megamount` and follow Library export best practices
|
||||||
|
- [x] Remove `bump` from `src` (BREAKING)
|
||||||
|
- [x] Remove `semver` from `src` (BREAKING)
|
||||||
|
|
||||||
|
## v1.2.1
|
||||||
|
|
||||||
|
Released: 2016-02-17.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.2.0...v1.2.1).
|
||||||
|
|
||||||
|
- [x] Add Travis CI automated testing for OSX (thanks @zbeekman)
|
||||||
|
|
||||||
|
## v1.2.0
|
||||||
|
|
||||||
|
Released: 2016-02-16.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.1.0...v1.2.0).
|
||||||
|
|
||||||
|
- [x] Allow disabling colors via `NO_COLOR` environment variable
|
||||||
|
- [x] Enable `errexit`, `nounset` and `pipefail` options at the top of the script already
|
||||||
|
- [x] More refined colors (thanks @arathai)
|
||||||
|
- [x] Add a changelog to the README
|
||||||
|
- [x] Add `__os` magic var (limited to discovering OSX and defaulting to Linux for now)
|
||||||
|
- [x] Add `__base` magic var (`main`, if the source script is `main.sh`)
|
||||||
|
- [x] Enable long, GNU style options (thanks @zbeekman)
|
||||||
|
- [x] Add Travis CI automated testing for Linux
|
||||||
|
|
||||||
|
## v1.1.0
|
||||||
|
|
||||||
|
Released: 2015-06-29.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/v1.0.3...v1.1.0).
|
||||||
|
|
||||||
|
- [x] Add `ALLOW_REMAINDERS` configuration to templater
|
||||||
|
- [x] Fix typo: 'debugmdoe' to 'debugmode' (thanks @jokajak)
|
||||||
|
- [x] Use `${BASH_SOURCE[0]}` for `__file` instead of `${0}`
|
||||||
|
|
||||||
|
## v1.0.3
|
||||||
|
|
||||||
|
Released: 2014-11-02.
|
||||||
|
[Diff](https://github.com/kvz/bash3boilerplate/compare/5db569125319a89b9561b434db84e4d91faefb63...v1.0.3).
|
||||||
|
|
||||||
|
- [x] Add `ini_val`, `megamount`, `parse_url`
|
||||||
|
- [x] Add re-usable libraries in `./src`
|
||||||
|
- [x] Use npm as an additional distribution channel
|
171
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/FAQ.md
generated
vendored
Normal file
171
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/FAQ.md
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
[This document is formatted with GitHub-Flavored Markdown. ]: #
|
||||||
|
[For better viewing, including hyperlinks, read it online at ]: #
|
||||||
|
[https://github.com/kvz/bash3boilerplate/blob/HEAD/FAQ.md ]: #
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- [What is a CLI](#what-is-a-cli)?
|
||||||
|
- [How do I incorporate BASH3 Boilerplate into my own project](#how-do-i-incorporate-bash3-boilerplate-into-my-own-project)?
|
||||||
|
- [How do I add a command-line flag](#how-do-i-add-a-command-line-flag)?
|
||||||
|
- [How do I access the value of a command-line argument](#how-do-i-access-the-value-of-a-command-line-argument)?
|
||||||
|
- [What is a magic variable](#what-is-a-magic-variable)?
|
||||||
|
- [How do I submit an issue report](#how-do-i-submit-an-issue-report)?
|
||||||
|
- [How can I contribute to this project](#how-can-i-contribute-to-this-project)?
|
||||||
|
- [Why are you typing BASH in all caps](#why-are-you-typing-bash-in-all-caps)?
|
||||||
|
- [You are saying you are portable, but why won't b3bp code run in dash / busybox / posh / ksh / mksh / zsh](#you-are-saying-you-are-portable-but-why-wont-b3bp-code-run-in-dash--busybox--posh--ksh--mksh--zsh)?
|
||||||
|
- [How do I do Operating System detection](#how-do-i-do-operating-system-detection)?
|
||||||
|
- [How do I access a potentially unset (environment) variable](#how-do-i-access-a-potentially-unset-environment-variable)?
|
||||||
|
- [How can I detect or trap CTRL-C and other signals](#how-can-i-detect-or-trap-ctrl-c-and-other-signals)?
|
||||||
|
- [How can I get the PID of my running script](how-can-i-get-the-pid-of-my-running-script)?
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
# Frequently Asked Questions
|
||||||
|
|
||||||
|
## What is a CLI?
|
||||||
|
|
||||||
|
A "CLI" is a [command-line interface](https://en.wikipedia.org/wiki/Command-line_interface).
|
||||||
|
|
||||||
|
## How do I incorporate BASH3 Boilerplate into my own project?
|
||||||
|
|
||||||
|
You can incorporate BASH3 Boilerplate into your project in one of two ways:
|
||||||
|
|
||||||
|
1. Copy the desired portions of [`main.sh`](http://bash3boilerplate.sh/main.sh) into your own script.
|
||||||
|
1. Download [`main.sh`](http://bash3boilerplate.sh/main.sh) and start pressing the delete-key to remove unwanted things
|
||||||
|
|
||||||
|
Once the `main.sh` has been tailor-made for your project, you can either append your own script in the same file, or source it in the following ways:
|
||||||
|
|
||||||
|
1. Copy [`main.sh`](http://bash3boilerplate.sh/main.sh) into the same directory as your script and then edit and embed it into your script using Bash's `source` include feature, e.g.:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
source main.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Source [`main.sh`](http://bash3boilerplate.sh/main.sh) in your script or at the command line:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
source main.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## How do I add a command-line flag?
|
||||||
|
|
||||||
|
1. Copy the line from the `main.sh` [read block](https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L109-L115) that most resembles the desired behavior and paste the line into the same block.
|
||||||
|
1. Edit the single-character (e.g., `-d`) and, if present, the multi-character (e.g., `--debug`) versions of the flag in the copied line.
|
||||||
|
1. Omit the `[arg]` text in the copied line, if the desired flag takes no arguments.
|
||||||
|
1. Omit or edit the text after `Default=` to set or not set default values, respectively.
|
||||||
|
1. Omit the `Required.` text, if the flag is optional.
|
||||||
|
|
||||||
|
## How do I access the value of a command-line argument?
|
||||||
|
|
||||||
|
To find out the value of an argument, append the corresponding single-character flag to the text `$arg_`. For example, if the [read block]
|
||||||
|
contains the line
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-t --temp [arg] Location of tempfile. Default="/tmp/bar"
|
||||||
|
```
|
||||||
|
|
||||||
|
then you can evaluate the corresponding argument and assign it to a variable as follows:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
__temp_file_name="${arg_t}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## What is a magic variable?
|
||||||
|
|
||||||
|
The [magic variables](https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L26-L28) in `main.sh` are special in that they have a different value, depending on your environment. You can use `${__file}` to get a reference to your current script, and `${__dir}` to get a reference to the directory it lives in. This is not to be confused with the location of the calling script that might be sourcing the `${__file}`, which is accessible via `${0}`, or the current directory of the administrator running the script, accessible via `$(pwd)`.
|
||||||
|
|
||||||
|
## How do I submit an issue report?
|
||||||
|
|
||||||
|
Please visit our [Issues](https://github.com/kvz/bash3boilerplate/issues) page.
|
||||||
|
|
||||||
|
## How can I contribute to this project?
|
||||||
|
|
||||||
|
Please fork this repository. After that, create a branch containing your suggested changes and submit a pull request based on the main branch
|
||||||
|
of <https://github.com/kvz/bash3boilerplate/>. We are always more than happy to accept your contributions!
|
||||||
|
|
||||||
|
## Why are you typing BASH in all caps?
|
||||||
|
|
||||||
|
As an acronym, Bash stands for Bourne-again shell, and is usually written with one uppercase.
|
||||||
|
This project's name, however, is "BASH3 Boilerplate". It is a reference to
|
||||||
|
"[HTML5 Boilerplate](https://html5boilerplate.com/)", which was founded to serve a similar purpose,
|
||||||
|
only for crafting webpages.
|
||||||
|
Somewhat inconsistent – but true to Unix ancestry – the abbreviation for our project is "b3bp".
|
||||||
|
|
||||||
|
## You are saying you are portable, but why won't b3bp code run in dash / busybox / posh / ksh / mksh / zsh?
|
||||||
|
|
||||||
|
When we say _portable_, we mean across Bash versions. Bash is widespread and most systems
|
||||||
|
offer at least version 3 of it. Make sure you have that available and b3bp will work for you.
|
||||||
|
|
||||||
|
We run automated tests to make sure that it will. Here is some proof for the following platforms:
|
||||||
|
|
||||||
|
- [Linux](https://travis-ci.org/kvz/bash3boilerplate/jobs/109804166#L91-L94) `GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)`
|
||||||
|
- [OSX](https://travis-ci.org/kvz/bash3boilerplate/jobs/109804167#L2453-L2455) `GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)`
|
||||||
|
|
||||||
|
This portability, however, does not mean that we try to be compatible with
|
||||||
|
KornShell, Zsh, posh, yash, dash, or other shells. We allow syntax that would explode if
|
||||||
|
you pasted it in anything but Bash 3 and up.
|
||||||
|
|
||||||
|
## How do I do Operating System detection?
|
||||||
|
|
||||||
|
We used to offer a magic `__os` variable, but we quickly [discovered](https://github.com/kvz/bash3boilerplate/issues/38) that it would be hard
|
||||||
|
to create a satisfactory abstraction that is not only correct, but also covers enough use-cases,
|
||||||
|
while still having a relatively small footprint in `main.sh`.
|
||||||
|
|
||||||
|
For simple OS detection, we recommend using the `${OSTYPE}` variable available in Bash as
|
||||||
|
is demoed in [this stackoverflow post](http://stackoverflow.com/a/8597411/151666):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if [[ "${OSTYPE}" = "linux-gnu" ]]; then
|
||||||
|
echo "GNU Linux"
|
||||||
|
elif [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||||
|
echo "Mac OSX"
|
||||||
|
elif [[ "${OSTYPE}" = "cygwin" ]]; then
|
||||||
|
echo "POSIX compatibility layer and Linux environment emulation for Windows"
|
||||||
|
elif [[ "${OSTYPE}" = "msys" ]]; then
|
||||||
|
echo "Lightweight shell and GNU utilities compiled for Windows (part of MinGW)"
|
||||||
|
elif [[ "${OSTYPE}" = "win32" ]]; then
|
||||||
|
echo "I'm not sure this can happen."
|
||||||
|
elif [[ "${OSTYPE}" = "freebsd"* ]]; then
|
||||||
|
echo "..."
|
||||||
|
else
|
||||||
|
echo "Unknown."
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
## How do I access a potentially unset (environment) variable?
|
||||||
|
|
||||||
|
The set -o nounset line in `main.sh` causes error termination when an unset environment variables is detected as unbound. There are multiple ways to avoid this.
|
||||||
|
|
||||||
|
Some code to illustrate:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# method 1
|
||||||
|
echo ${NAME1:-Damian} # echos Damian, $NAME1 is still unset
|
||||||
|
# method 2
|
||||||
|
echo ${NAME2:=Damian} # echos Damian, $NAME2 is set to Damian
|
||||||
|
# method 3
|
||||||
|
NAME3=${NAME3:-Damian}; echo ${NAME3} # echos Damian, $NAME3 is set to Damian
|
||||||
|
```
|
||||||
|
|
||||||
|
This subject is briefly touched on as well in the [Safety and Portability section under point 5](README.md#safety-and-portability). b3bp currently uses [method 1](https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L252) when we want to access a variable that could be undeclared, and [method 3](https://github.com/kvz/bash3boilerplate/blob/v2.1.0/main.sh#L31) when we also want to set a default to an undeclared variable, because we feel it is more readable than method 2. We feel `:=` is easily overlooked, and not very beginner friendly. Method 3 seems more explicit in that regard in our humble opinion.
|
||||||
|
|
||||||
|
## How can I detect or trap Ctrl-C and other signals?
|
||||||
|
|
||||||
|
You can trap [Unix signals](https://en.wikipedia.org/wiki/Unix_signal) like [Ctrl-C](https://en.wikipedia.org/wiki/Control-C) with code similar to:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# trap ctrl-c and call ctrl_c()
|
||||||
|
trap ctrl_c INT
|
||||||
|
|
||||||
|
function ctrl_c() {
|
||||||
|
echo "** Trapped CTRL-C"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See http://mywiki.wooledge.org/SignalTrap for a list of signals, examples, and an in depth discussion.
|
||||||
|
|
||||||
|
## How can I get the PID of my running script?
|
||||||
|
|
||||||
|
The PID of a running script is contained in the `${$}` variable. This is _not_ the pid of any subshells. With Bash 4 you can get the PID of your subshell with `${BASHPID}`. For a comprehensive list of Bash built in variables see, e.g., http://www.tldp.org/LDP/abs/html/internalvariables.html
|
21
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/LICENSE
generated
vendored
Normal file
21
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
59
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/Makefile
generated
vendored
Normal file
59
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/Makefile
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# Licensed under MIT.
|
||||||
|
# Copyright (2016) by Kevin van Zonneveld https://twitter.com/kvz
|
||||||
|
#
|
||||||
|
# https://www.npmjs.com/package/fakefile
|
||||||
|
#
|
||||||
|
# Please do not edit this file directly, but propose changed upstream instead:
|
||||||
|
# https://github.com/kvz/fakefile/blob/main/Makefile
|
||||||
|
#
|
||||||
|
# This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
|
||||||
|
# It functions as a wrapper around the actual listed in `package.json`
|
||||||
|
# So instead of typing:
|
||||||
|
#
|
||||||
|
# $ npm script build:assets
|
||||||
|
#
|
||||||
|
# you could also type:
|
||||||
|
#
|
||||||
|
# $ make build-assets
|
||||||
|
#
|
||||||
|
# Notice that colons (:) are replaced by dashes for Makefile compatibility.
|
||||||
|
#
|
||||||
|
# The benefits of this wrapper are:
|
||||||
|
#
|
||||||
|
# - You get to keep the the scripts package.json, which is more portable
|
||||||
|
# (Makefiles & Windows are harder to mix)
|
||||||
|
# - Offer a polite way into the project for developers coming from different
|
||||||
|
# languages (npm scripts is obviously very Node centric)
|
||||||
|
# - Profit from better autocomplete (make <TAB><TAB>) than npm currently offers.
|
||||||
|
# OSX users will have to install bash-completion
|
||||||
|
# (http://davidalger.com/development/bash-completion-on-os-x-with-brew/)
|
||||||
|
|
||||||
|
ifeq ($(shell test -e ./yarn.lock && echo -n yes),yes)
|
||||||
|
RUNNER=yarn
|
||||||
|
INSTALLER=yarn install
|
||||||
|
else
|
||||||
|
RUNNER=npm run
|
||||||
|
INSTALLER=npm install
|
||||||
|
endif
|
||||||
|
|
||||||
|
define npm_script_targets
|
||||||
|
TARGETS := $(shell \
|
||||||
|
node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}'
|
||||||
|
| grep -v -E "^install$$"
|
||||||
|
)
|
||||||
|
$$(TARGETS):
|
||||||
|
$(RUNNER) $(shell \
|
||||||
|
node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"), k);}'
|
||||||
|
| grep -E "^$(MAKECMDGOALS)\s"
|
||||||
|
| head -n1
|
||||||
|
| awk '{print $$2}'
|
||||||
|
)
|
||||||
|
|
||||||
|
.PHONY: $$(TARGETS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call npm_script_targets))
|
||||||
|
|
||||||
|
# These npm run scripts are available, without needing to be mentioned in `package.json`
|
||||||
|
install:
|
||||||
|
$(INSTALLER)
|
175
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/README.md
generated
vendored
Normal file
175
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/README.md
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
[This document is formatted with GitHub-Flavored Markdown. ]: #
|
||||||
|
[For better viewing, including hyperlinks, read it online at ]: #
|
||||||
|
[https://github.com/kvz/bash3boilerplate/blob/HEAD/README.md]: #
|
||||||
|
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [Goals](#goals)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Changelog](#changelog)
|
||||||
|
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||||
|
- [Best Practices](#best-practices)
|
||||||
|
- [Who uses b3bp](#who-uses-b3bp)
|
||||||
|
- [Authors](#authors)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
When hacking up Bash scripts, there are often things such as logging or command-line argument parsing that:
|
||||||
|
|
||||||
|
- You need every time
|
||||||
|
- Come with a number of pitfalls you want to avoid
|
||||||
|
- Keep you from your actual work
|
||||||
|
|
||||||
|
Here's an attempt to bundle those things in a generalized way so that
|
||||||
|
they are reusable as-is in most scripts.
|
||||||
|
|
||||||
|
We call it "BASH3 Boilerplate" or b3bp for short.
|
||||||
|
|
||||||
|
## Goals
|
||||||
|
|
||||||
|
Delete-Key-**Friendly**. Instead of introducing packages, includes, compilers, etc., we propose using [`main.sh`](https://bash3boilerplate.sh/main.sh) as a base and removing the parts you don't need.
|
||||||
|
While this may feel a bit archaic at first, it is exactly the strength of Bash scripts that we should want to embrace.
|
||||||
|
|
||||||
|
**Portable**. We are targeting Bash 3 (OSX still ships
|
||||||
|
with 3, for instance). If you are going to ask people to install
|
||||||
|
Bash 4 first, you might as well pick a more advanced language as a
|
||||||
|
dependency.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Conventions that will make sure that all your scripts follow the same, battle-tested structure
|
||||||
|
- Safe by default (break on error, pipefail, etc.)
|
||||||
|
- Configuration by environment variables
|
||||||
|
- Simple command-line argument parsing that requires no external dependencies. Definitions are parsed from help info, ensuring there will be no duplication
|
||||||
|
- Helpful magic variables like `__file` and `__dir`
|
||||||
|
- Logging that supports colors and is compatible with [Syslog Severity levels](https://en.wikipedia.org/wiki/Syslog#Severity_levels), as well as the [twelve-factor](https://12factor.net/) guidelines
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
There are three different ways to install b3bp:
|
||||||
|
|
||||||
|
### Option 1: Download the main template
|
||||||
|
|
||||||
|
Use curl or wget to download the source and save it as your script. Then you can start deleting the unwanted bits, and adding your own logic.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget https://bash3boilerplate.sh/main.sh
|
||||||
|
vim main.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Clone the entire project
|
||||||
|
|
||||||
|
Besides `main.sh`, this will also get you the entire b3bp repository. This includes a few extra functions that we keep in the `./src` directory.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:kvz/bash3boilerplate.git
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 3: Require via npm
|
||||||
|
|
||||||
|
As of `v1.0.3`, b3bp can also be installed as a Node module, meaning you can define it as a dependency in `package.json` via:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm init
|
||||||
|
npm install --save --save-exact bash3boilerplate
|
||||||
|
```
|
||||||
|
|
||||||
|
Even though this option introduces a Node.js dependency, it does allow for easy version pinning and distribution in environments that already have this prerequisite. This is, however, entirely optional and nothing prevents you from ignoring this possibility.
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
Please see the [CHANGELOG.md](./CHANGELOG.md) file.
|
||||||
|
|
||||||
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
Please see the [FAQ.md](./FAQ.md) file.
|
||||||
|
|
||||||
|
## Best practices
|
||||||
|
|
||||||
|
As of `v1.0.3`, b3bp offers some nice re-usable libraries in `./src`. In order to make the snippets in `./src` more useful, we recommend the following guidelines.
|
||||||
|
|
||||||
|
### Function packaging
|
||||||
|
|
||||||
|
It is nice to have a Bash package that can not only be used in the terminal, but also invoked as a command line function. In order to achieve this, the exporting of your functionality _should_ follow this pattern:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
|
||||||
|
my_script "${@}"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
export -f my_script
|
||||||
|
```
|
||||||
|
|
||||||
|
This allows a user to `source` your script or invoke it as a script.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Running as a script
|
||||||
|
$ ./my_script.sh some args --blah
|
||||||
|
# Sourcing the script
|
||||||
|
$ source my_script.sh
|
||||||
|
$ my_script some more args --blah
|
||||||
|
```
|
||||||
|
|
||||||
|
(taken from the [bpkg](https://raw.githubusercontent.com/bpkg/bpkg/HEAD/README.md) project)
|
||||||
|
|
||||||
|
### Scoping
|
||||||
|
|
||||||
|
1. In functions, use `local` before every variable declaration.
|
||||||
|
1. Use `UPPERCASE_VARS` to indicate environment variables that can be controlled outside your script.
|
||||||
|
1. Use `__double_underscore_prefixed_vars` to indicate global variables that are solely controlled inside your script, with the exception of arguments that are already prefixed with `arg_`, as well as functions, over which b3bp poses no restrictions.
|
||||||
|
|
||||||
|
### Coding style
|
||||||
|
|
||||||
|
1. Use two spaces for tabs, do not use tab characters.
|
||||||
|
1. Do not introduce whitespace at the end of lines or on blank lines as they obfuscate version control diffs.
|
||||||
|
1. Use long options (`logger --priority` vs `logger -p`). If you are on the CLI, abbreviations make sense for efficiency. Nevertheless, when you are writing reusable scripts, a few extra keystrokes will pay off in readability and avoid ventures into man pages in the future, either by you or your collaborators. Similarly, we prefer `set -o nounset` over `set -u`.
|
||||||
|
1. Use a single equal sign when checking `if [[ "${NAME}" = "Kevin" ]]`; double or triple signs are not needed.
|
||||||
|
1. Use the new bash builtin test operator (`[[ ... ]]`) rather than the old single square bracket test operator or explicit call to `test`.
|
||||||
|
|
||||||
|
### Safety and Portability
|
||||||
|
|
||||||
|
1. Use `{}` to enclose your variables. Otherwise, Bash will try to access the `$ENVIRONMENT_app` variable in `/srv/$ENVIRONMENT_app`, whereas you probably intended `/srv/${ENVIRONMENT}_app`. Since it is easy to miss cases like this, we recommend that you make enclosing a habit.
|
||||||
|
1. Use `set`, rather than relying on a shebang like `#!/usr/bin/env bash -e`, since that is neutralized when someone runs your script as `bash yourscript.sh`.
|
||||||
|
1. Use `#!/usr/bin/env bash`, as it is more portable than `#!/bin/bash`.
|
||||||
|
1. Use `${BASH_SOURCE[0]}` if you refer to current file, even if it is sourced by a parent script. In other cases, use `${0}`.
|
||||||
|
1. Use `:-` if you want to test variables that could be undeclared. For instance, with `if [[ "${NAME:-}" = "Kevin" ]]`, `$NAME` will evaluate to `Kevin` if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is `${NAME:=Kevin}`.
|
||||||
|
|
||||||
|
## Who uses b3bp?
|
||||||
|
|
||||||
|
- [Transloadit](https://transloadit.com)
|
||||||
|
- [OpenCoarrays](https://www.opencoarrays.org)
|
||||||
|
- [Sourcery Institute](https://www.sourceryinstitute.org)
|
||||||
|
- [Computational Brain Anatomy Laboratory](https://cobralab.ca/)
|
||||||
|
- [Genesis Cloud](https://genesiscloud.com/)
|
||||||
|
|
||||||
|
We are looking for endorsements! Are you also using b3bp? [Let us know](https://github.com/kvz/bash3boilerplate/issues/new?title=I%20use%20b3bp) and get listed.
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
- [Kevin van Zonneveld](https://kvz.io)
|
||||||
|
- [Izaak Beekman](https://izaakbeekman.com/)
|
||||||
|
- [Manuel Streuhofer](https://github.com/mstreuhofer)
|
||||||
|
- [Alexander Rathai](mailto:Alexander.Rathai@gmail.com)
|
||||||
|
- [Dr. Damian Rouson](https://www.sourceryinstitute.org/) (documentation, feedback)
|
||||||
|
- [@jokajak](https://github.com/jokajak) (documentation)
|
||||||
|
- [Gabriel A. Devenyi](https://staticwave.ca/) (feedback)
|
||||||
|
- [@bravo-kernel](https://github.com/bravo-kernel) (feedback)
|
||||||
|
- [@skanga](https://github.com/skanga) (feedback)
|
||||||
|
- [galaktos](https://www.reddit.com/user/galaktos) (feedback)
|
||||||
|
- [@moviuro](https://github.com/moviuro) (feedback)
|
||||||
|
- [Giovanni Saponaro](https://github.com/gsaponaro) (feedback)
|
||||||
|
- [Germain Masse](https://github.com/gmasse)
|
||||||
|
- [A. G. Madi](https://github.com/warpengineer)
|
||||||
|
- [Lukas Stockner](mailto:oss@genesiscloud.com)
|
||||||
|
- [Gert Goet](https://github.com/eval)
|
||||||
|
- [@rfuehrer](https://github.com/rfuehrer)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2013 Kevin van Zonneveld and [contributors](https://github.com/kvz/bash3boilerplate#authors).
|
||||||
|
Licensed under [MIT](https://raw.githubusercontent.com/kvz/bash3boilerplate/HEAD/LICENSE).
|
||||||
|
You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
as you leave these references intact in the header comments of your source files.
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/docs/CNAME
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/docs/CNAME
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
bash3boilerplate.sh
|
15
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/docs/index.html
generated
vendored
Normal file
15
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/docs/index.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta
|
||||||
|
http-equiv="refresh"
|
||||||
|
content="0;url=https://github.com/kvz/bash3boilerplate"
|
||||||
|
/>
|
||||||
|
<title>Redirecting...</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
If you are not redirected,
|
||||||
|
<a href="https://github.com/kvz/bash3boilerplate">click here</a>.
|
||||||
|
</body>
|
||||||
|
</html>
|
147
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/example.sh
generated
vendored
Executable file
147
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/example.sh
generated
vendored
Executable file
@ -0,0 +1,147 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Demos BASH3 Boilerplate (change this for your script)
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# LOG_LEVEL=7 ./example.sh -f /tmp/x -d (change this for your script)
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate v2.3.0
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
|
||||||
|
### BASH3 Boilerplate (b3bp) Header
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Commandline options. This defines the usage page, and is used to parse cli
|
||||||
|
# opts & defaults from. The parsing is unforgiving so be precise in your syntax
|
||||||
|
# - A short option must be preset for every long option; but every short option
|
||||||
|
# need not have a long option
|
||||||
|
# - `--` is respected as the separator between options and arguments
|
||||||
|
# - We do not bash-expand defaults, so setting '~/app' as a default will not resolve to ${HOME}.
|
||||||
|
# you can use bash variables to work around this (so use ${HOME} instead)
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
-f --file [arg] Filename to process. Required.
|
||||||
|
-t --temp [arg] Location of tempfile. Default="/tmp/bar"
|
||||||
|
-v Enable verbose mode, print script as it is executed
|
||||||
|
-d --debug Enables debug mode
|
||||||
|
-h --help This page
|
||||||
|
-n --no-color Disable color output
|
||||||
|
-1 --one Do just one thing
|
||||||
|
-i --input [arg] File to process. Can be repeated.
|
||||||
|
-x Specify a flag. Can be repeated.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
read -r -d '' __helptext <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# shellcheck source=main.sh
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/main.sh"
|
||||||
|
|
||||||
|
|
||||||
|
### Signal trapping and backtracing
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
function __b3bp_cleanup_before_exit () {
|
||||||
|
info "Cleaning up. Done"
|
||||||
|
}
|
||||||
|
trap __b3bp_cleanup_before_exit EXIT
|
||||||
|
|
||||||
|
# requires `set -o errtrace`
|
||||||
|
__b3bp_err_report() {
|
||||||
|
local error_code=${?}
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
error "Error in ${__file} in function ${1} on line ${2}"
|
||||||
|
exit ${error_code}
|
||||||
|
}
|
||||||
|
# Uncomment the following line for always providing an error backtrace
|
||||||
|
# trap '__b3bp_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
|
||||||
|
|
||||||
|
|
||||||
|
### Command-line argument switches (like -d for debugmode, -h for showing helppage)
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# debug mode
|
||||||
|
if [[ "${arg_d:?}" = "1" ]]; then
|
||||||
|
set -o xtrace
|
||||||
|
PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
|
LOG_LEVEL="7"
|
||||||
|
# Enable error backtracing
|
||||||
|
trap '__b3bp_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# verbose mode
|
||||||
|
if [[ "${arg_v:?}" = "1" ]]; then
|
||||||
|
set -o verbose
|
||||||
|
fi
|
||||||
|
|
||||||
|
# no color mode
|
||||||
|
if [[ "${arg_n:?}" = "1" ]]; then
|
||||||
|
NO_COLOR="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# help mode
|
||||||
|
if [[ "${arg_h:?}" = "1" ]]; then
|
||||||
|
# Help exists with code 1
|
||||||
|
help "Help using ${0}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
### Validation. Error out if the things required for your script are not present
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
[[ "${arg_f:-}" ]] || help "Setting a filename with -f or --file is required"
|
||||||
|
[[ "${LOG_LEVEL:-}" ]] || emergency "Cannot continue without LOG_LEVEL. "
|
||||||
|
|
||||||
|
|
||||||
|
### Runtime
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
info "__i_am_main_script: ${__i_am_main_script}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
info "__file: ${__file}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
info "__dir: ${__dir}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
info "__base: ${__base}"
|
||||||
|
info "OSTYPE: ${OSTYPE}"
|
||||||
|
|
||||||
|
info "arg_f: ${arg_f}"
|
||||||
|
info "arg_d: ${arg_d}"
|
||||||
|
info "arg_v: ${arg_v}"
|
||||||
|
info "arg_h: ${arg_h}"
|
||||||
|
if [[ -n "${arg_i:-}" ]]; then
|
||||||
|
info "arg_i: ${#arg_i[@]}"
|
||||||
|
for input_file in "${arg_i[@]}"; do
|
||||||
|
info " - ${input_file}"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
info "arg_i: 0"
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
[[ -n "${arg_x:-}" ]] && info "arg_x: ${#arg_x[@]}" || info "arg_x: 0"
|
||||||
|
|
||||||
|
info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - line #2\\nimagine logging the output of 'ls -al /path/'")"
|
||||||
|
|
||||||
|
# All of these go to STDERR, so you can use STDOUT for piping machine readable information to other software
|
||||||
|
debug "Info useful to developers for debugging the application, not useful during operations."
|
||||||
|
info "Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required."
|
||||||
|
notice "Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required."
|
||||||
|
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time."
|
||||||
|
error "Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time."
|
||||||
|
critical "Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection."
|
||||||
|
alert "Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection."
|
||||||
|
emergency "A \"panic\" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call."
|
453
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/main.sh
generated
vendored
Executable file
453
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/main.sh
generated
vendored
Executable file
@ -0,0 +1,453 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Demos BASH3 Boilerplate (change this for your script)
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# LOG_LEVEL=7 ./main.sh -f /tmp/x -d (change this for your script)
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
# Exit on error. Append "|| true" if you expect an error.
|
||||||
|
set -o errexit
|
||||||
|
# Exit on error inside any functions or subshells.
|
||||||
|
set -o errtrace
|
||||||
|
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
|
||||||
|
set -o nounset
|
||||||
|
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
|
||||||
|
set -o pipefail
|
||||||
|
# Turn on traces, useful while debugging but commented out by default
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||||
|
__i_am_main_script="0" # false
|
||||||
|
|
||||||
|
if [[ "${__usage+x}" ]]; then
|
||||||
|
if [[ "${BASH_SOURCE[1]}" = "${0}" ]]; then
|
||||||
|
__i_am_main_script="1" # true
|
||||||
|
fi
|
||||||
|
|
||||||
|
__b3bp_external_usage="true"
|
||||||
|
__b3bp_tmp_source_idx=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
__i_am_main_script="1" # true
|
||||||
|
[[ "${__usage+x}" ]] && unset -v __usage
|
||||||
|
[[ "${__helptext+x}" ]] && unset -v __helptext
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set magic variables for current file, directory, os, etc.
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")" && pwd)"
|
||||||
|
__file="${__dir}/$(basename "${BASH_SOURCE[${__b3bp_tmp_source_idx:-0}]}")"
|
||||||
|
__base="$(basename "${__file}" .sh)"
|
||||||
|
# shellcheck disable=SC2034,SC2015
|
||||||
|
__invocation="$(printf %q "${__file}")$( (($#)) && printf ' %q' "$@" || true)"
|
||||||
|
|
||||||
|
# Define the environment variables (and their defaults) that this script depends on
|
||||||
|
LOG_LEVEL="${LOG_LEVEL:-6}" # 7 = debug -> 0 = emergency
|
||||||
|
NO_COLOR="${NO_COLOR:-}" # true = disable color. otherwise autodetected
|
||||||
|
|
||||||
|
|
||||||
|
### Functions
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
function __b3bp_log () {
|
||||||
|
local log_level="${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_debug="\\x1b[35m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_info="\\x1b[32m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_notice="\\x1b[34m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_warning="\\x1b[33m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_error="\\x1b[31m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_critical="\\x1b[1;31m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_alert="\\x1b[1;37;41m"
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
local color_emergency="\\x1b[1;4;5;37;41m"
|
||||||
|
|
||||||
|
local colorvar="color_${log_level}"
|
||||||
|
|
||||||
|
local color="${!colorvar:-${color_error}}"
|
||||||
|
local color_reset="\\x1b[0m"
|
||||||
|
|
||||||
|
if [[ "${NO_COLOR:-}" = "true" ]] || { [[ "${TERM:-}" != "xterm"* ]] && [[ "${TERM:-}" != "screen"* ]]; } || [[ ! -t 2 ]]; then
|
||||||
|
if [[ "${NO_COLOR:-}" != "false" ]]; then
|
||||||
|
# Don't use colors on pipes or non-recognized terminals
|
||||||
|
color=""; color_reset=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# all remaining arguments are to be printed
|
||||||
|
local log_line=""
|
||||||
|
|
||||||
|
while IFS=$'\n' read -r log_line; do
|
||||||
|
echo -e "$(date -u +"%Y-%m-%d %H:%M:%S UTC") ${color}$(printf "[%9s]" "${log_level}")${color_reset} ${log_line}" 1>&2
|
||||||
|
done <<< "${@:-}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function emergency () { __b3bp_log emergency "${@}"; exit 1; }
|
||||||
|
function alert () { [[ "${LOG_LEVEL:-0}" -ge 1 ]] && __b3bp_log alert "${@}"; true; }
|
||||||
|
function critical () { [[ "${LOG_LEVEL:-0}" -ge 2 ]] && __b3bp_log critical "${@}"; true; }
|
||||||
|
function error () { [[ "${LOG_LEVEL:-0}" -ge 3 ]] && __b3bp_log error "${@}"; true; }
|
||||||
|
function warning () { [[ "${LOG_LEVEL:-0}" -ge 4 ]] && __b3bp_log warning "${@}"; true; }
|
||||||
|
function notice () { [[ "${LOG_LEVEL:-0}" -ge 5 ]] && __b3bp_log notice "${@}"; true; }
|
||||||
|
function info () { [[ "${LOG_LEVEL:-0}" -ge 6 ]] && __b3bp_log info "${@}"; true; }
|
||||||
|
function debug () { [[ "${LOG_LEVEL:-0}" -ge 7 ]] && __b3bp_log debug "${@}"; true; }
|
||||||
|
|
||||||
|
function help () {
|
||||||
|
echo "" 1>&2
|
||||||
|
echo " ${*}" 1>&2
|
||||||
|
echo "" 1>&2
|
||||||
|
echo " ${__usage:-No usage available}" 1>&2
|
||||||
|
echo "" 1>&2
|
||||||
|
|
||||||
|
if [[ "${__helptext:-}" ]]; then
|
||||||
|
echo " ${__helptext}" 1>&2
|
||||||
|
echo "" 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Parse commandline options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Commandline options. This defines the usage page, and is used to parse cli
|
||||||
|
# opts & defaults from. The parsing is unforgiving so be precise in your syntax
|
||||||
|
# - A short option must be preset for every long option; but every short option
|
||||||
|
# need not have a long option
|
||||||
|
# - `--` is respected as the separator between options and arguments
|
||||||
|
# - We do not bash-expand defaults, so setting '~/app' as a default will not resolve to ${HOME}.
|
||||||
|
# you can use bash variables to work around this (so use ${HOME} instead)
|
||||||
|
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
[[ "${__usage+x}" ]] || read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
-f --file [arg] Filename to process. Required.
|
||||||
|
-t --temp [arg] Location of tempfile. Default="/tmp/bar"
|
||||||
|
-v Enable verbose mode, print script as it is executed
|
||||||
|
-d --debug Enables debug mode
|
||||||
|
-h --help This page
|
||||||
|
-n --no-color Disable color output
|
||||||
|
-1 --one Do just one thing
|
||||||
|
-i --input [arg] File to process. Can be repeated.
|
||||||
|
-x Specify a flag. Can be repeated.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
[[ "${__helptext+x}" ]] || read -r -d '' __helptext <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Translate usage string -> getopts arguments, and set $arg_<flag> defaults
|
||||||
|
while read -r __b3bp_tmp_line; do
|
||||||
|
if [[ "${__b3bp_tmp_line}" =~ ^- ]]; then
|
||||||
|
# fetch single character version of option string
|
||||||
|
__b3bp_tmp_opt="${__b3bp_tmp_line%% *}"
|
||||||
|
__b3bp_tmp_opt="${__b3bp_tmp_opt:1}"
|
||||||
|
|
||||||
|
# fetch long version if present
|
||||||
|
__b3bp_tmp_long_opt=""
|
||||||
|
|
||||||
|
if [[ "${__b3bp_tmp_line}" = *"--"* ]]; then
|
||||||
|
__b3bp_tmp_long_opt="${__b3bp_tmp_line#*--}"
|
||||||
|
__b3bp_tmp_long_opt="${__b3bp_tmp_long_opt%% *}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# map opt long name to+from opt short name
|
||||||
|
printf -v "__b3bp_tmp_opt_long2short_${__b3bp_tmp_long_opt//-/_}" '%s' "${__b3bp_tmp_opt}"
|
||||||
|
printf -v "__b3bp_tmp_opt_short2long_${__b3bp_tmp_opt}" '%s' "${__b3bp_tmp_long_opt//-/_}"
|
||||||
|
|
||||||
|
# check if option takes an argument
|
||||||
|
if [[ "${__b3bp_tmp_line}" =~ \[.*\] ]]; then
|
||||||
|
__b3bp_tmp_opt="${__b3bp_tmp_opt}:" # add : if opt has arg
|
||||||
|
__b3bp_tmp_init="" # it has an arg. init with ""
|
||||||
|
printf -v "__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}" '%s' "1"
|
||||||
|
elif [[ "${__b3bp_tmp_line}" =~ \{.*\} ]]; then
|
||||||
|
__b3bp_tmp_opt="${__b3bp_tmp_opt}:" # add : if opt has arg
|
||||||
|
__b3bp_tmp_init="" # it has an arg. init with ""
|
||||||
|
# remember that this option requires an argument
|
||||||
|
printf -v "__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}" '%s' "2"
|
||||||
|
else
|
||||||
|
__b3bp_tmp_init="0" # it's a flag. init with 0
|
||||||
|
printf -v "__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}" '%s' "0"
|
||||||
|
fi
|
||||||
|
__b3bp_tmp_opts="${__b3bp_tmp_opts:-}${__b3bp_tmp_opt}"
|
||||||
|
|
||||||
|
if [[ "${__b3bp_tmp_line}" =~ ^Can\ be\ repeated\. ]] || [[ "${__b3bp_tmp_line}" =~ \.\ *Can\ be\ repeated\. ]]; then
|
||||||
|
# remember that this option can be repeated
|
||||||
|
printf -v "__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}" '%s' "1"
|
||||||
|
else
|
||||||
|
printf -v "__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}" '%s' "0"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "${__b3bp_tmp_opt:-}" ]] || continue
|
||||||
|
|
||||||
|
if [[ "${__b3bp_tmp_line}" =~ ^Default= ]] || [[ "${__b3bp_tmp_line}" =~ \.\ *Default= ]]; then
|
||||||
|
# ignore default value if option does not have an argument
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}"
|
||||||
|
if [[ "${!__b3bp_tmp_varname}" != "0" ]]; then
|
||||||
|
# take default
|
||||||
|
__b3bp_tmp_init="${__b3bp_tmp_line##*Default=}"
|
||||||
|
# strip double quotes from default argument
|
||||||
|
__b3bp_tmp_re='^"(.*)"$'
|
||||||
|
if [[ "${__b3bp_tmp_init}" =~ ${__b3bp_tmp_re} ]]; then
|
||||||
|
__b3bp_tmp_init="${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
# strip single quotes from default argument
|
||||||
|
__b3bp_tmp_re="^'(.*)'$"
|
||||||
|
if [[ "${__b3bp_tmp_init}" =~ ${__b3bp_tmp_re} ]]; then
|
||||||
|
__b3bp_tmp_init="${BASH_REMATCH[1]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${__b3bp_tmp_line}" =~ ^Required\. ]] || [[ "${__b3bp_tmp_line}" =~ \.\ *Required\. ]]; then
|
||||||
|
# remember that this option requires an argument
|
||||||
|
printf -v "__b3bp_tmp_has_arg_${__b3bp_tmp_opt:0:1}" '%s' "2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Init var with value unless it is an array / a repeatable
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}"
|
||||||
|
[[ "${!__b3bp_tmp_varname}" = "0" ]] && printf -v "arg_${__b3bp_tmp_opt:0:1}" '%s' "${__b3bp_tmp_init}"
|
||||||
|
done <<< "${__usage:-}"
|
||||||
|
|
||||||
|
# run getopts only if options were specified in __usage
|
||||||
|
if [[ "${__b3bp_tmp_opts:-}" ]]; then
|
||||||
|
# Allow long options like --this
|
||||||
|
__b3bp_tmp_opts="${__b3bp_tmp_opts}-:"
|
||||||
|
|
||||||
|
# Reset in case getopts has been used previously in the shell.
|
||||||
|
OPTIND=1
|
||||||
|
|
||||||
|
# start parsing command line
|
||||||
|
set +o nounset # unexpected arguments will cause unbound variables
|
||||||
|
# to be dereferenced
|
||||||
|
# Overwrite $arg_<flag> defaults with the actual CLI options
|
||||||
|
while getopts "${__b3bp_tmp_opts}" __b3bp_tmp_opt; do
|
||||||
|
[[ "${__b3bp_tmp_opt}" = "?" ]] && help "Invalid use of script: ${*} "
|
||||||
|
|
||||||
|
if [[ "${__b3bp_tmp_opt}" = "-" ]]; then
|
||||||
|
# OPTARG is long-option-name or long-option=value
|
||||||
|
if [[ "${OPTARG}" =~ .*=.* ]]; then
|
||||||
|
# --key=value format
|
||||||
|
__b3bp_tmp_long_opt=${OPTARG/=*/}
|
||||||
|
# Set opt to the short option corresponding to the long option
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_opt_long2short_${__b3bp_tmp_long_opt//-/_}"
|
||||||
|
printf -v "__b3bp_tmp_opt" '%s' "${!__b3bp_tmp_varname}"
|
||||||
|
OPTARG=${OPTARG#*=}
|
||||||
|
else
|
||||||
|
# --key value format
|
||||||
|
# Map long name to short version of option
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_opt_long2short_${OPTARG//-/_}"
|
||||||
|
printf -v "__b3bp_tmp_opt" '%s' "${!__b3bp_tmp_varname}"
|
||||||
|
# Only assign OPTARG if option takes an argument
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_has_arg_${__b3bp_tmp_opt}"
|
||||||
|
__b3bp_tmp_varvalue="${!__b3bp_tmp_varname}"
|
||||||
|
[[ "${__b3bp_tmp_varvalue}" != "0" ]] && __b3bp_tmp_varvalue="1"
|
||||||
|
printf -v "OPTARG" '%s' "${@:OPTIND:${__b3bp_tmp_varvalue}}"
|
||||||
|
# shift over the argument if argument is expected
|
||||||
|
((OPTIND+=__b3bp_tmp_varvalue))
|
||||||
|
fi
|
||||||
|
# we have set opt/OPTARG to the short value and the argument as OPTARG if it exists
|
||||||
|
fi
|
||||||
|
|
||||||
|
__b3bp_tmp_value="${OPTARG}"
|
||||||
|
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_is_array_${__b3bp_tmp_opt:0:1}"
|
||||||
|
if [[ "${!__b3bp_tmp_varname}" != "0" ]]; then
|
||||||
|
# repeatables
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
if [[ -z "${OPTARG}" ]]; then
|
||||||
|
# repeatable flags, they increcemnt
|
||||||
|
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}"
|
||||||
|
debug "cli arg ${__b3bp_tmp_varname} = (${__b3bp_tmp_default}) -> ${!__b3bp_tmp_varname}"
|
||||||
|
# shellcheck disable=SC2004
|
||||||
|
__b3bp_tmp_value=$((${!__b3bp_tmp_varname} + 1))
|
||||||
|
printf -v "${__b3bp_tmp_varname}" '%s' "${__b3bp_tmp_value}"
|
||||||
|
else
|
||||||
|
# repeatable args, they get appended to an array
|
||||||
|
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}[@]"
|
||||||
|
debug "cli arg ${__b3bp_tmp_varname} append ${__b3bp_tmp_value}"
|
||||||
|
declare -a "${__b3bp_tmp_varname}"='("${!__b3bp_tmp_varname}" "${__b3bp_tmp_value}")'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# non-repeatables
|
||||||
|
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt:0:1}"
|
||||||
|
__b3bp_tmp_default="${!__b3bp_tmp_varname}"
|
||||||
|
|
||||||
|
if [[ -z "${OPTARG}" ]]; then
|
||||||
|
__b3bp_tmp_value=$((__b3bp_tmp_default + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf -v "${__b3bp_tmp_varname}" '%s' "${__b3bp_tmp_value}"
|
||||||
|
|
||||||
|
debug "cli arg ${__b3bp_tmp_varname} = (${__b3bp_tmp_default}) -> ${!__b3bp_tmp_varname}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -o nounset # no more unbound variable references expected
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [[ "${1:-}" = "--" ]] ; then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
### Automatic validation of required option arguments
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
for __b3bp_tmp_varname in ${!__b3bp_tmp_has_arg_*}; do
|
||||||
|
# validate only options which required an argument
|
||||||
|
[[ "${!__b3bp_tmp_varname}" = "2" ]] || continue
|
||||||
|
|
||||||
|
__b3bp_tmp_opt_short="${__b3bp_tmp_varname##*_}"
|
||||||
|
__b3bp_tmp_varname="arg_${__b3bp_tmp_opt_short}"
|
||||||
|
[[ "${!__b3bp_tmp_varname}" ]] && continue
|
||||||
|
|
||||||
|
__b3bp_tmp_varname="__b3bp_tmp_opt_short2long_${__b3bp_tmp_opt_short}"
|
||||||
|
printf -v "__b3bp_tmp_opt_long" '%s' "${!__b3bp_tmp_varname}"
|
||||||
|
[[ "${__b3bp_tmp_opt_long:-}" ]] && __b3bp_tmp_opt_long=" (--${__b3bp_tmp_opt_long//_/-})"
|
||||||
|
|
||||||
|
help "Option -${__b3bp_tmp_opt_short}${__b3bp_tmp_opt_long:-} requires an argument"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
### Cleanup Environment variables
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
for __tmp_varname in ${!__b3bp_tmp_*}; do
|
||||||
|
unset -v "${__tmp_varname}"
|
||||||
|
done
|
||||||
|
|
||||||
|
unset -v __tmp_varname
|
||||||
|
|
||||||
|
|
||||||
|
### Externally supplied __usage. Nothing else to do here
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
if [[ "${__b3bp_external_usage:-}" = "true" ]]; then
|
||||||
|
unset -v __b3bp_external_usage
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
### Signal trapping and backtracing
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
function __b3bp_cleanup_before_exit () {
|
||||||
|
info "Cleaning up. Done"
|
||||||
|
}
|
||||||
|
trap __b3bp_cleanup_before_exit EXIT
|
||||||
|
|
||||||
|
# requires `set -o errtrace`
|
||||||
|
__b3bp_err_report() {
|
||||||
|
local error_code=${?}
|
||||||
|
error "Error in ${__file} in function ${1} on line ${2}"
|
||||||
|
exit ${error_code}
|
||||||
|
}
|
||||||
|
# Uncomment the following line for always providing an error backtrace
|
||||||
|
# trap '__b3bp_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
|
||||||
|
|
||||||
|
|
||||||
|
### Command-line argument switches (like -d for debugmode, -h for showing helppage)
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# debug mode
|
||||||
|
if [[ "${arg_d:?}" = "1" ]]; then
|
||||||
|
set -o xtrace
|
||||||
|
PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
|
LOG_LEVEL="7"
|
||||||
|
# Enable error backtracing
|
||||||
|
trap '__b3bp_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# verbose mode
|
||||||
|
if [[ "${arg_v:?}" = "1" ]]; then
|
||||||
|
set -o verbose
|
||||||
|
fi
|
||||||
|
|
||||||
|
# no color mode
|
||||||
|
if [[ "${arg_n:?}" = "1" ]]; then
|
||||||
|
NO_COLOR="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# help mode
|
||||||
|
if [[ "${arg_h:?}" = "1" ]]; then
|
||||||
|
# Help exists with code 1
|
||||||
|
help "Help using ${0}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
### Validation. Error out if the things required for your script are not present
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
[[ "${arg_f:-}" ]] || help "Setting a filename with -f or --file is required"
|
||||||
|
[[ "${LOG_LEVEL:-}" ]] || emergency "Cannot continue without LOG_LEVEL. "
|
||||||
|
|
||||||
|
|
||||||
|
### Runtime
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
info "__i_am_main_script: ${__i_am_main_script}"
|
||||||
|
info "__file: ${__file}"
|
||||||
|
info "__dir: ${__dir}"
|
||||||
|
info "__base: ${__base}"
|
||||||
|
info "OSTYPE: ${OSTYPE}"
|
||||||
|
|
||||||
|
info "arg_f: ${arg_f}"
|
||||||
|
info "arg_d: ${arg_d}"
|
||||||
|
info "arg_v: ${arg_v}"
|
||||||
|
info "arg_h: ${arg_h}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
if [[ -n "${arg_i:-}" ]] && declare -p arg_i 2> /dev/null | grep -q '^declare \-a'; then
|
||||||
|
info "arg_i:"
|
||||||
|
for input_file in "${arg_i[@]}"; do
|
||||||
|
info " - ${input_file}"
|
||||||
|
done
|
||||||
|
elif [[ -n "${arg_i:-}" ]]; then
|
||||||
|
info "arg_i: ${arg_i}"
|
||||||
|
else
|
||||||
|
info "arg_i: 0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
if [[ -n "${arg_x:-}" ]] && declare -p arg_x 2> /dev/null | grep -q '^declare \-a'; then
|
||||||
|
info "arg_x: ${#arg_x[@]}"
|
||||||
|
elif [[ -n "${arg_x:-}" ]]; then
|
||||||
|
info "arg_x: ${arg_x}"
|
||||||
|
else
|
||||||
|
info "arg_x: 0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - line #2\\nimagine logging the output of 'ls -al /path/'")"
|
||||||
|
|
||||||
|
# All of these go to STDERR, so you can use STDOUT for piping machine readable information to other software
|
||||||
|
debug "Info useful to developers for debugging the application, not useful during operations."
|
||||||
|
info "Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required."
|
||||||
|
notice "Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required."
|
||||||
|
warning "Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time."
|
||||||
|
error "Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time."
|
||||||
|
critical "Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection."
|
||||||
|
alert "Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection."
|
||||||
|
emergency "A \"panic\" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call."
|
29
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/package.json
generated
vendored
Normal file
29
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/package.json
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "bash3boilerplate",
|
||||||
|
"description": "Copypastable templates to write better bash scripts",
|
||||||
|
"version": "2.7.2",
|
||||||
|
"packageManager": "yarn@3.6.0+sha224.19e47520fa56c6146388fdeb438d9dcf6630c3f277a2e1180995c3bb",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18",
|
||||||
|
"yarn": "3.6.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint:shellcheck": "shellcheck --severity=${SHELLCHECK_SEVERITY:-info} $(find . -name '*.sh' -maxdepth 2)",
|
||||||
|
"lint:style": "test/style.pl $(find . -name '*.sh' -maxdepth 2)",
|
||||||
|
"lint": "npm-run-all -l 'lint:**'",
|
||||||
|
"release:major": "env SEMANTIC=major yarn release",
|
||||||
|
"release:minor": "env SEMANTIC=minor yarn release",
|
||||||
|
"release:patch": "env SEMANTIC=patch yarn release",
|
||||||
|
"release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && yarn version:replace && git commit main.sh src/*.sh -m 'Update version' && git push && git push --tags -f && npm publish",
|
||||||
|
"test:debug:main:repeated": "env LOG_LEVEL=7 test/acceptance.sh main-repeated",
|
||||||
|
"test:update": "env SAVE_FIXTURES=true yarn test",
|
||||||
|
"test": "test/acceptance.sh",
|
||||||
|
"version:current": "node -e 'console.log(require(\"./package.json\").version)'",
|
||||||
|
"version:replace": "replace 'v\\d+\\.\\d+\\.\\d+' \"v$(npm run --silent version:current)\" main.sh src/*.sh"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"fakefile": "1.1.0",
|
||||||
|
"npm-run-all": "4.1.5",
|
||||||
|
"replace": "1.2.2"
|
||||||
|
}
|
||||||
|
}
|
113
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/ini_val.sh
generated
vendored
Executable file
113
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/ini_val.sh
generated
vendored
Executable file
@ -0,0 +1,113 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# BASH3 Boilerplate: ini_val
|
||||||
|
#
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Can read and write .ini files using pure bash
|
||||||
|
#
|
||||||
|
# Limitations:
|
||||||
|
#
|
||||||
|
# - All keys inside a section of the .ini file must be unique
|
||||||
|
# - Optional comment parameter for the creation of new entries
|
||||||
|
#
|
||||||
|
# Usage as a function:
|
||||||
|
#
|
||||||
|
# source ini_val.sh
|
||||||
|
# ini_val data.ini connection.host 127.0.0.1 "Host name or IP address"
|
||||||
|
#
|
||||||
|
# Usage as a command:
|
||||||
|
#
|
||||||
|
# ini_val.sh data.ini connection.host 127.0.0.1 "Host name or IP address"
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
function ini_val() {
|
||||||
|
local file="${1:-}"
|
||||||
|
local sectionkey="${2:-}"
|
||||||
|
local val="${3:-}"
|
||||||
|
local comment="${4:-}"
|
||||||
|
local delim="="
|
||||||
|
local comment_delim=";"
|
||||||
|
local section=""
|
||||||
|
local key=""
|
||||||
|
local current=""
|
||||||
|
# add default section
|
||||||
|
local section_default="default"
|
||||||
|
|
||||||
|
if [[ ! -f "${file}" ]]; then
|
||||||
|
# touch file if not exists
|
||||||
|
touch "${file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split on . for section. However, section is optional
|
||||||
|
IFS='.' read -r section key <<< "${sectionkey}"
|
||||||
|
if [[ ! "${key}" ]]; then
|
||||||
|
key="${section}"
|
||||||
|
# default section if not given
|
||||||
|
section="${section_default}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get current value (if exists)
|
||||||
|
current=$(sed -En "/^\[/{h;d;};G;s/^${key}([[:blank:]]*)${delim}(.*)\n\[${section}\]$/\2/p" "${file}"|awk '{$1=$1};1')
|
||||||
|
# get current comment (if exists)
|
||||||
|
current_comment=$(sed -En "/^\[${section}\]/,/^\[.*\]/ s|^(${comment_delim}\[${key}\])(.*)|\2|p" "${file}"|awk '{$1=$1};1')
|
||||||
|
|
||||||
|
if ! grep -q "\[${section}\]" "${file}"; then
|
||||||
|
# create section if not exists (empty line to seperate new section for better readability)
|
||||||
|
echo >> "${file}"
|
||||||
|
echo "[${section}]" >> "${file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "${val}" ]]; then
|
||||||
|
# get a value
|
||||||
|
echo "${current}"
|
||||||
|
else
|
||||||
|
# set a value
|
||||||
|
if [[ ! "${section}" ]]; then
|
||||||
|
# if no section is given, propagate the default section
|
||||||
|
section=${section_default}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "${comment}" ]]; then
|
||||||
|
# if no comment given, keep old comment
|
||||||
|
comment="${current_comment}"
|
||||||
|
fi
|
||||||
|
# maintenance area
|
||||||
|
# a) remove comment if new given / respect section
|
||||||
|
sed -i.bak "/^\[${section}\]/,/^\[.*\]/ s|^\(${comment_delim}\[${key}\] \).*$||" "${file}"
|
||||||
|
# b) remove old key / respect section
|
||||||
|
sed -i.bak "/^\[${section}\]/,/^\[.*\]/ s|^\(${key}=\).*$||" "${file}"
|
||||||
|
# c) remove all empty lines in ini file
|
||||||
|
sed -i.bak '/^[[:space:]]*$/d' "${file}"
|
||||||
|
# d) insert line break before every section for better readability
|
||||||
|
sed -i.bak $'s/^\\[/\\\n\\[/g' "${file}"
|
||||||
|
|
||||||
|
# add to section
|
||||||
|
if [[ ! "${comment}" ]]; then
|
||||||
|
# add new key/value _without_ comment
|
||||||
|
RET="/\\[${section}\\]/a\\
|
||||||
|
${key}${delim}${val}"
|
||||||
|
else
|
||||||
|
# add new key/value _with_ preceeding comment
|
||||||
|
RET="/\\[${section}\\]/a\\
|
||||||
|
${comment_delim}[${key}] ${comment}\\
|
||||||
|
${key}${delim}${val}"
|
||||||
|
fi
|
||||||
|
sed -i.bak -e "${RET}" "${file}"
|
||||||
|
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||||
|
rm -f "${file}.bak"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||||
|
export -f ini_val
|
||||||
|
else
|
||||||
|
ini_val "${@}"
|
||||||
|
exit ${?}
|
||||||
|
fi
|
78
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/megamount.sh
generated
vendored
Normal file
78
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/megamount.sh
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# BASH3 Boilerplate: megamount
|
||||||
|
#
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Takes a URL (smb, nfs, afs) and tries to mount it at a given target directory
|
||||||
|
# - Forcefully unmounts any active mount at the target directory first
|
||||||
|
# - Displays the mount's contents for verification
|
||||||
|
#
|
||||||
|
# Depends on:
|
||||||
|
#
|
||||||
|
# - ./parse_url.sh
|
||||||
|
#
|
||||||
|
# Usage as a function:
|
||||||
|
#
|
||||||
|
# source megamount.sh
|
||||||
|
# megamount smb://janedoe:abc123@192.168.0.1/documents /mnt/documents
|
||||||
|
#
|
||||||
|
# Usage as a command:
|
||||||
|
#
|
||||||
|
# megamount.sh smb://janedoe:abc123@192.168.0.1/documents /mnt/documents
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=src/parse_url.sh
|
||||||
|
source "${__dir}/parse_url.sh"
|
||||||
|
|
||||||
|
function megamount () {
|
||||||
|
local url="${1}"
|
||||||
|
local target="${2}"
|
||||||
|
|
||||||
|
local proto
|
||||||
|
local user
|
||||||
|
local pass
|
||||||
|
local host
|
||||||
|
local port
|
||||||
|
local path
|
||||||
|
|
||||||
|
proto=$(parse_url "${url}" "proto")
|
||||||
|
user=$(parse_url "${url}" "user")
|
||||||
|
pass=$(parse_url "${url}" "pass")
|
||||||
|
host=$(parse_url "${url}" "host")
|
||||||
|
port=$(parse_url "${url}" "port")
|
||||||
|
path=$(parse_url "${url}" "path")
|
||||||
|
|
||||||
|
(umount -lf "${target}" || umount -f "${target}") > /dev/null 2>&1 || true
|
||||||
|
mkdir -p "${target}"
|
||||||
|
if [[ "${proto}" = "smb://" ]]; then
|
||||||
|
mount -t cifs --verbose -o "username=${user},password=${pass},hard" "//${host}/${path}" "${target}"
|
||||||
|
elif [[ "${proto}" = "afp://" ]]; then
|
||||||
|
# start syslog-ng
|
||||||
|
# afpfsd || echo "Unable to run afpfsd. Does /dev/log exist?" && exit 1
|
||||||
|
mount_afp "${url}" "${target}"
|
||||||
|
elif [[ "${proto}" = "nfs://" ]]; then
|
||||||
|
mount -t nfs --verbose -o "vers=3,nolock,soft,intr,rsize=32768,wsize=32768" "${host}:/${path}" "${target}"
|
||||||
|
else
|
||||||
|
echo "ERR: Unknown protocol: '${proto}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# chmod 777 "${target}"
|
||||||
|
ls -al "${target}/"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||||
|
export -f megamount
|
||||||
|
else
|
||||||
|
megamount "${@}"
|
||||||
|
exit ${?}
|
||||||
|
fi
|
84
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/parse_url.sh
generated
vendored
Normal file
84
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/parse_url.sh
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# BASH3 Boilerplate: parse_url
|
||||||
|
#
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Takes a URL and parses protocol, user, pass, host, port, path.
|
||||||
|
#
|
||||||
|
# Based on:
|
||||||
|
#
|
||||||
|
# - http://stackoverflow.com/a/6174447/151666
|
||||||
|
#
|
||||||
|
# Usage as a function:
|
||||||
|
#
|
||||||
|
# source parse_url.sh
|
||||||
|
# parse_url 'http://johndoe:abc123@example.com:8080/index.html' pass
|
||||||
|
#
|
||||||
|
# Usage as a command:
|
||||||
|
#
|
||||||
|
# parse_url.sh 'http://johndoe:abc123@example.com:8080/index.html'
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
function parse_url() {
|
||||||
|
local parse="${1}"
|
||||||
|
local need="${2:-}"
|
||||||
|
|
||||||
|
local proto
|
||||||
|
local url
|
||||||
|
local userpass
|
||||||
|
local user
|
||||||
|
local pass
|
||||||
|
local hostport
|
||||||
|
local host
|
||||||
|
local port
|
||||||
|
local path
|
||||||
|
|
||||||
|
proto="$(echo "${parse}" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
||||||
|
url="${parse/${proto}/}"
|
||||||
|
userpass="$(echo "${url}" | grep @ | cut -d@ -f1)"
|
||||||
|
user="$(echo "${userpass}" | grep : | cut -d: -f1)"
|
||||||
|
pass="$(echo "${userpass}" | grep : | cut -d: -f2)"
|
||||||
|
hostport="$(echo "${url/${userpass}@/}" | cut -d/ -f1)"
|
||||||
|
host="$(echo "${hostport}" | grep : | cut -d: -f1)"
|
||||||
|
port="$(echo "${hostport}" | grep : | cut -d: -f2)"
|
||||||
|
path="$(echo "${url}" | grep / | cut -d/ -f2-)"
|
||||||
|
|
||||||
|
[[ ! "${user}" ]] && user="${userpass}"
|
||||||
|
[[ ! "${host}" ]] && host="${hostport}"
|
||||||
|
if [[ ! "${port}" ]]; then
|
||||||
|
[[ "${proto}" = "http://" ]] && port="80"
|
||||||
|
[[ "${proto}" = "https://" ]] && port="443"
|
||||||
|
[[ "${proto}" = "mysql://" ]] && port="3306"
|
||||||
|
[[ "${proto}" = "redis://" ]] && port="6379"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${need}" ]]; then
|
||||||
|
echo "${!need}"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo " Use second argument to return just 1 variable."
|
||||||
|
echo " parse_url() demo: "
|
||||||
|
echo ""
|
||||||
|
echo " proto: ${proto}"
|
||||||
|
echo " user: ${user}"
|
||||||
|
echo " pass: ${pass}"
|
||||||
|
echo " host: ${host}"
|
||||||
|
echo " port: ${port}"
|
||||||
|
echo " path: ${path}"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||||
|
export -f parse_url
|
||||||
|
else
|
||||||
|
parse_url "${@}"
|
||||||
|
exit ${?}
|
||||||
|
fi
|
68
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/templater.sh
generated
vendored
Executable file
68
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/src/templater.sh
generated
vendored
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# BASH3 Boilerplate: templater
|
||||||
|
#
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - takes a source (template) & destination (config) filepath argument
|
||||||
|
# - then replaces placeholders with variables found in the environment
|
||||||
|
#
|
||||||
|
# Usage as a function:
|
||||||
|
#
|
||||||
|
# source templater.sh
|
||||||
|
# export NAME=kevin
|
||||||
|
# templater input.cfg output.cfg
|
||||||
|
#
|
||||||
|
# Usage as a command:
|
||||||
|
#
|
||||||
|
# ALLOW_REMAINDERS=1 templater.sh input.cfg output.cfg
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate vv2.7.2
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
function templater() {
|
||||||
|
ALLOW_REMAINDERS="${ALLOW_REMAINDERS:-0}"
|
||||||
|
|
||||||
|
templateSrc="${1:-}"
|
||||||
|
templateDst="${2:-}"
|
||||||
|
|
||||||
|
if [[ ! -f "${templateSrc}" ]]; then
|
||||||
|
echo "ERROR: Template source '${templateSrc}' needs to exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! "${templateDst}" ]]; then
|
||||||
|
echo "ERROR: Template destination '${templateDst}' needs to be specified"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$(command -v perl)" ]]; then
|
||||||
|
perl -p -e 's/\$\{(\w+)\}/(exists $ENV{$1} ? $ENV{$1} : "\${$1}")/eg' < "${templateSrc}" > "${templateDst}"
|
||||||
|
else
|
||||||
|
cp -f "${templateSrc}" "${templateDst}"
|
||||||
|
|
||||||
|
for var in $(env |awk -F= '{print $1}' |grep -E '^(_[A-Z0-9_]+|[A-Z0-9][A-Z0-9_]*)$'); do
|
||||||
|
sed -i.bak -e "s#\${${var}}#${!var//#/\\#/}#g" "${templateDst}"
|
||||||
|
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||||
|
rm -f "${templateDst}.bak"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cat "${templateDst}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
if grep '${' "${templateDst}" && [[ "${ALLOW_REMAINDERS}" = "0" ]]; then
|
||||||
|
echo "ERROR: Unable to replace the above template vars"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||||
|
export -f templater
|
||||||
|
else
|
||||||
|
templater "${@}"
|
||||||
|
exit ${?}
|
||||||
|
fi
|
232
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/acceptance.sh
generated
vendored
Executable file
232
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/acceptance.sh
generated
vendored
Executable file
@ -0,0 +1,232 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This file:
|
||||||
|
#
|
||||||
|
# - Executes one (or all) test scenarios
|
||||||
|
# - Replaces dynamic things like hostnames, IPs, dates, etc
|
||||||
|
# - Optionally saves the results as fixtures, that later runs will be compared against
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# ./deploy.sh
|
||||||
|
#
|
||||||
|
# Based on a template by BASH3 Boilerplate v2.0.0
|
||||||
|
# http://bash3boilerplate.sh/#authors
|
||||||
|
#
|
||||||
|
# The MIT License (MIT)
|
||||||
|
# Copyright (c) 2013 Kevin van Zonneveld and contributors
|
||||||
|
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
|
||||||
|
# as you leave these references intact in the header comments of your source files.
|
||||||
|
|
||||||
|
# Exit on error. Append || true if you expect an error.
|
||||||
|
set -o errexit
|
||||||
|
# Exit on error inside any functions or subshells.
|
||||||
|
set -o errtrace
|
||||||
|
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
|
||||||
|
set -o nounset
|
||||||
|
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump |gzip`
|
||||||
|
set -o pipefail
|
||||||
|
# Turn on traces, useful while debugging but commented out by default
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
# Set magic variables for current file, directory, os, etc.
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
__base="$(basename "${__file}" .sh)"
|
||||||
|
__root="$(cd "$(dirname "${__dir}")" && pwd)"
|
||||||
|
|
||||||
|
__sysTmpDir="${TMPDIR:-/tmp}"
|
||||||
|
__sysTmpDir="${__sysTmpDir%/}" # <-- remove trailing slash on macosx
|
||||||
|
__accptstTmpDir=$(mktemp -d "${__sysTmpDir}/${__base}.XXXXXX")
|
||||||
|
|
||||||
|
function cleanup_before_exit () { rm -r "${__accptstTmpDir:?}"; }
|
||||||
|
trap cleanup_before_exit EXIT
|
||||||
|
|
||||||
|
cmdSed="sed"
|
||||||
|
cmdTimeout="timeout"
|
||||||
|
|
||||||
|
if [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||||
|
cmdSed="gsed"
|
||||||
|
cmdTimeout="gtimeout"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$(command -v ${cmdSed})" ]]; then
|
||||||
|
echo "Please install ${cmdSed}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$(command -v ${cmdTimeout})" ]]; then
|
||||||
|
echo "Please install ${cmdTimeout}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
__node="$(command -v node)"
|
||||||
|
__arch="amd64"
|
||||||
|
|
||||||
|
# explicitly setting NO_COLOR to false will make b3bp ignore TERM
|
||||||
|
# not being "xterm*" or "screen*" and STDERR not being connected to a terminal
|
||||||
|
# it's the opposite of NO_COLOR="true" - it forces color, no matter what
|
||||||
|
export NO_COLOR="false"
|
||||||
|
|
||||||
|
# Running prepare before other scenarios is important on Travis,
|
||||||
|
# so that stdio can diverge - and we can enforce stricter
|
||||||
|
# stdio comparison on all other tests.
|
||||||
|
while IFS=$'\n' read -r scenario; do
|
||||||
|
scenario="$(dirname "${scenario}")"
|
||||||
|
scenario="${scenario##${__dir}/scenario/}"
|
||||||
|
|
||||||
|
[[ "${scenario}" = "prepare" ]] && continue
|
||||||
|
[[ "${1:-}" ]] && [[ "${scenario}" != "${1}" ]] && continue
|
||||||
|
|
||||||
|
echo "==> Scenario: ${scenario}"
|
||||||
|
pushd "${__dir}/scenario/${scenario}" > /dev/null
|
||||||
|
|
||||||
|
# Run scenario
|
||||||
|
(${cmdTimeout} --kill-after=6m 5m bash ./run.sh \
|
||||||
|
> "${__accptstTmpDir}/${scenario}.stdio" 2>&1; \
|
||||||
|
echo "${?}" > "${__accptstTmpDir}/${scenario}.exitcode" \
|
||||||
|
) || true
|
||||||
|
|
||||||
|
# Clear out environmental specifics
|
||||||
|
for typ in stdio exitcode; do
|
||||||
|
curFile="${__accptstTmpDir}/${scenario}.${typ}"
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-e "s@${__node}@{node}@g" "${curFile}" \
|
||||||
|
-e "s@${__root}@{root}@g" "${curFile}" \
|
||||||
|
-e "s@${__sysTmpDir}@{tmpdir}@g" "${curFile}" \
|
||||||
|
-e "s@/tmp@{tmpdir}@g" "${curFile}" \
|
||||||
|
-e "s@${HOME:-/home/travis}@{home}@g" "${curFile}" \
|
||||||
|
-e "s@${USER:-travis}@{user}@g" "${curFile}" \
|
||||||
|
-e "s@travis@{user}@g" "${curFile}" \
|
||||||
|
-e "s@kvz@{user}@g" "${curFile}" \
|
||||||
|
-e "s@{root}/node_modules/\\.bin/node@{node}@g" "${curFile}" \
|
||||||
|
-e "s@{home}/build/{user}/fre{node}@{node}@g" "${curFile}" \
|
||||||
|
-e "s@${HOSTNAME}@{hostname}@g" "${curFile}" \
|
||||||
|
-e "s@${__arch}@{arch}@g" "${curFile}" \
|
||||||
|
-e "s@${OSTYPE}@{OSTYPE}@g" "${curFile}" \
|
||||||
|
-e "s@OSX@{os}@g" "${curFile}" \
|
||||||
|
-e "s@Linux@{os}@g" "${curFile}" \
|
||||||
|
|| false
|
||||||
|
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_IPS' "${curFile}"; then
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}@{ip}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
|
||||||
|
# IPs vary in length. Ansible uses padding. {ip} does not vary in length
|
||||||
|
# so kill the padding after it for consistent output
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@\{ip\}\s+@{ip} @g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_UUIDS' "${curFile}"; then
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9a-f\-]{32,40}@{uuid}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_BIGINTS' "${curFile}"; then
|
||||||
|
# Such as: 3811298194
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9]{7,64}@{bigint}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_DATETIMES' "${curFile}"; then
|
||||||
|
# Such as: 2016-02-10 15:38:44.420094
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}@{datetime}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_LONGTIMES' "${curFile}"; then
|
||||||
|
# Such as: 2016-02-10 15:38:44.420094
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{longtime}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_DURATIONS' "${curFile}"; then
|
||||||
|
# Such as: 0:00:00.001991
|
||||||
|
"${cmdSed}" -i \
|
||||||
|
-r 's@[0-9]{1,2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{duration}@g' \
|
||||||
|
"${curFile}"
|
||||||
|
fi
|
||||||
|
if grep -q 'ACCPTST:STDIO_REPLACE_REMOTE_EXEC' "${curFile}"; then
|
||||||
|
grep -Ev 'remote-exec\): [ a-zA-Z]' "${curFile}" > "${__sysTmpDir}/accptst-filtered.txt"
|
||||||
|
mv "${__sysTmpDir}/accptst-filtered.txt" "${curFile}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Save these as new fixtures?
|
||||||
|
if [[ "${SAVE_FIXTURES:-}" = "true" ]]; then
|
||||||
|
for typ in stdio exitcode; do
|
||||||
|
curFile="${__accptstTmpDir}/${scenario}.${typ}"
|
||||||
|
cp -f \
|
||||||
|
"${curFile}" \
|
||||||
|
"${__dir}/fixture/${scenario}.${typ}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compare
|
||||||
|
for typ in stdio exitcode; do
|
||||||
|
curFile="${__accptstTmpDir}/${scenario}.${typ}"
|
||||||
|
|
||||||
|
echo -n " comparing ${typ}.. "
|
||||||
|
|
||||||
|
if [[ "${typ}" = "stdio" ]]; then
|
||||||
|
if grep -q 'ACCPTST:STDIO_SKIP_COMPARE' "${curFile}"; then
|
||||||
|
echo "skip"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! diff --strip-trailing-cr "${__dir}/fixture/${scenario}.${typ}" "${curFile}"; then
|
||||||
|
echo -e "\\n\\n==> MISMATCH OF: ${scenario}.${typ} ---^"
|
||||||
|
echo -e "\\n\\n==> EXPECTED STDIO: "
|
||||||
|
cat "${__dir}/fixture/${scenario}.stdio" || true
|
||||||
|
echo -e "\\n\\n==> ACTUAL STDIO: "
|
||||||
|
cat "${__accptstTmpDir}/${scenario}.stdio" || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓"
|
||||||
|
done
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
done <<< "$(find "${__dir}/scenario" -type f -iname 'run.sh')"
|
||||||
|
|
||||||
|
[[ "${1:-}" ]] && exit 0
|
||||||
|
|
||||||
|
# Ensure correct syntax with all available bashes
|
||||||
|
|
||||||
|
# shellcheck disable=SC2230
|
||||||
|
# "command -v" is not a substitute for "which -a"
|
||||||
|
while IFS=$'\n' read -r bash; do
|
||||||
|
if [[ "${bash:-}" = "" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
|
||||||
|
pushd "${__root}" > /dev/null
|
||||||
|
|
||||||
|
failed="false"
|
||||||
|
|
||||||
|
while IFS=$'\n' read -r file; do
|
||||||
|
[[ "${file}" =~ ^\./node_modules/ ]] && continue
|
||||||
|
|
||||||
|
echo -n " ${file}.. "
|
||||||
|
|
||||||
|
if ! "${bash}" -n "${file}" 2>> "${__accptstTmpDir}/${bash//\//.}.err"; then
|
||||||
|
echo "✗"
|
||||||
|
failed="true"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓"
|
||||||
|
done <<< "$(find . -type f -iname '*.sh')"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
if [[ "${failed}" = "true" ]]; then
|
||||||
|
cat "${__accptstTmpDir}/${bash//\//.}.err"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done <<< "$(which -a bash 2>/dev/null)"
|
||||||
|
|
||||||
|
exit 0
|
0
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/.empty
generated
vendored
Normal file
0
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/.empty
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/double-source.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/double-source.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/double-source.stdio
generated
vendored
Normal file
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/double-source.stdio
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [35m[ debug][0m cli arg arg_f = () -> {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m __i_am_main_script: 0
|
||||||
|
{datetime} UTC [32m[ info][0m __file: {root}/example.sh
|
||||||
|
{datetime} UTC [32m[ info][0m __dir: {root}
|
||||||
|
{datetime} UTC [32m[ info][0m __base: example
|
||||||
|
{datetime} UTC [32m[ info][0m OSTYPE: {OSTYPE}
|
||||||
|
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m arg_d: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_v: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_h: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_i: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_x: 0
|
||||||
|
{datetime} UTC [32m[ info][0m multiple lines example - line #1
|
||||||
|
{datetime} UTC [32m[ info][0m multiple lines example - line #2
|
||||||
|
{datetime} UTC [32m[ info][0m imagine logging the output of 'ls -al /path/'
|
||||||
|
{datetime} UTC [35m[ debug][0m Info useful to developers for debugging the application, not useful during operations.
|
||||||
|
{datetime} UTC [32m[ info][0m Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||||
|
{datetime} UTC [34m[ notice][0m Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||||
|
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [31m[ error][0m Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [1;31m[ critical][0m Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||||
|
{datetime} UTC [1;37;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||||
|
{datetime} UTC [1;4;5;37;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||||
|
{datetime} UTC [32m[ info][0m Cleaning up. Done
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/ini_val.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/ini_val.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
42
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/ini_val.stdio
generated
vendored
Normal file
42
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/ini_val.stdio
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
--> command: Read 3 values
|
||||||
|
exists
|
||||||
|
127.0.0.1
|
||||||
|
nginx, nodejs
|
||||||
|
|
||||||
|
--> command: Replace three values in-place and show result
|
||||||
|
|
||||||
|
[default]
|
||||||
|
orphan=no more
|
||||||
|
|
||||||
|
[connection]
|
||||||
|
host=192.168.0.1
|
||||||
|
|
||||||
|
[software]
|
||||||
|
packages=vim
|
||||||
|
|
||||||
|
[comment]
|
||||||
|
;[command] got this new comment
|
||||||
|
command=works like a chame
|
||||||
|
;[new_command] last addition will be moved downwards again after next command
|
||||||
|
new_command=commented too
|
||||||
|
--> function: Read 3 values
|
||||||
|
exists
|
||||||
|
127.0.0.1
|
||||||
|
nginx, nodejs
|
||||||
|
|
||||||
|
--> function: Replace three values in-place and show result
|
||||||
|
|
||||||
|
[default]
|
||||||
|
orphan=no more
|
||||||
|
|
||||||
|
[connection]
|
||||||
|
host=192.168.0.1
|
||||||
|
|
||||||
|
[software]
|
||||||
|
packages=vim
|
||||||
|
|
||||||
|
[comment]
|
||||||
|
;[command] got this new comment
|
||||||
|
command=works like a chame
|
||||||
|
;[new_command] last addition will be moved downwards again after next command
|
||||||
|
new_command=commented too
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-debug.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-debug.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-debug.stdio
generated
vendored
Normal file
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-debug.stdio
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [35m[ debug][0m cli arg arg_f = () -> {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m __i_am_main_script: 1
|
||||||
|
{datetime} UTC [32m[ info][0m __file: {root}/main.sh
|
||||||
|
{datetime} UTC [32m[ info][0m __dir: {root}
|
||||||
|
{datetime} UTC [32m[ info][0m __base: main
|
||||||
|
{datetime} UTC [32m[ info][0m OSTYPE: {OSTYPE}
|
||||||
|
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m arg_d: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_v: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_h: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_i: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_x: 0
|
||||||
|
{datetime} UTC [32m[ info][0m multiple lines example - line #1
|
||||||
|
{datetime} UTC [32m[ info][0m multiple lines example - line #2
|
||||||
|
{datetime} UTC [32m[ info][0m imagine logging the output of 'ls -al /path/'
|
||||||
|
{datetime} UTC [35m[ debug][0m Info useful to developers for debugging the application, not useful during operations.
|
||||||
|
{datetime} UTC [32m[ info][0m Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||||
|
{datetime} UTC [34m[ notice][0m Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||||
|
{datetime} UTC [33m[ warning][0m Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [31m[ error][0m Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [1;31m[ critical][0m Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||||
|
{datetime} UTC [1;37;41m[ alert][0m Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||||
|
{datetime} UTC [1;4;5;37;41m[emergency][0m A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||||
|
{datetime} UTC [32m[ info][0m Cleaning up. Done
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-help.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-help.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
19
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-help.stdio
generated
vendored
Normal file
19
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-help.stdio
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
|
||||||
|
Help using {root}/main.sh
|
||||||
|
|
||||||
|
-f --file [arg] Filename to process. Required.
|
||||||
|
-t --temp [arg] Location of tempfile. Default="{tmpdir}/bar"
|
||||||
|
-v Enable verbose mode, print script as it is executed
|
||||||
|
-d --debug Enables debug mode
|
||||||
|
-h --help This page
|
||||||
|
-n --no-color Disable color output
|
||||||
|
-1 --one Do just one thing
|
||||||
|
-i --input [arg] File to process. Can be repeated.
|
||||||
|
-x Specify a flag. Can be repeated.
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
{datetime} UTC [32m[ info][0m Cleaning up. Done
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-longopt.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-longopt.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
4
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-longopt.stdio
generated
vendored
Normal file
4
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-longopt.stdio
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
||||||
|
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-nocolor.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-nocolor.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-nocolor.stdio
generated
vendored
Normal file
25
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-nocolor.stdio
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [ debug] cli arg arg_f = () -> {tmpdir}/x
|
||||||
|
{datetime} UTC [ info] __i_am_main_script: 1
|
||||||
|
{datetime} UTC [ info] __file: {root}/main.sh
|
||||||
|
{datetime} UTC [ info] __dir: {root}
|
||||||
|
{datetime} UTC [ info] __base: main
|
||||||
|
{datetime} UTC [ info] OSTYPE: {OSTYPE}
|
||||||
|
{datetime} UTC [ info] arg_f: {tmpdir}/x
|
||||||
|
{datetime} UTC [ info] arg_d: 0
|
||||||
|
{datetime} UTC [ info] arg_v: 0
|
||||||
|
{datetime} UTC [ info] arg_h: 0
|
||||||
|
{datetime} UTC [ info] arg_i: 0
|
||||||
|
{datetime} UTC [ info] arg_x: 0
|
||||||
|
{datetime} UTC [ info] multiple lines example - line #1
|
||||||
|
{datetime} UTC [ info] multiple lines example - line #2
|
||||||
|
{datetime} UTC [ info] imagine logging the output of 'ls -al /path/'
|
||||||
|
{datetime} UTC [ debug] Info useful to developers for debugging the application, not useful during operations.
|
||||||
|
{datetime} UTC [ info] Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required.
|
||||||
|
{datetime} UTC [ notice] Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
|
||||||
|
{datetime} UTC [ warning] Warning messages, not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [ error] Non-urgent failures, these should be relayed to developers or admins; each item must be resolved within a given time.
|
||||||
|
{datetime} UTC [ critical] Should be corrected immediately, but indicates failure in a primary system, an example is a loss of a backup ISP connection.
|
||||||
|
{datetime} UTC [ alert] Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection.
|
||||||
|
{datetime} UTC [emergency] A "panic" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call.
|
||||||
|
{datetime} UTC [ info] Cleaning up. Done
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-repeated.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-repeated.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
9
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-repeated.stdio
generated
vendored
Normal file
9
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-repeated.stdio
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [32m[ info][0m arg_i:
|
||||||
|
{datetime} UTC [32m[ info][0m - simple_input
|
||||||
|
{datetime} UTC [32m[ info][0m - input_in_quotes
|
||||||
|
{datetime} UTC [32m[ info][0m - input with spaces
|
||||||
|
{datetime} UTC [32m[ info][0m - input with "quotes"
|
||||||
|
{datetime} UTC [32m[ info][0m - last_input
|
||||||
|
{datetime} UTC [32m[ info][0m arg_x: 3
|
||||||
|
{datetime} UTC [32m[ info][0m arg_x: 4
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-defaults.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-defaults.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
7
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-defaults.stdio
generated
vendored
Normal file
7
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-defaults.stdio
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
{datetime} UTC [32m[ info][0m arg_1: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_2: 0
|
||||||
|
{datetime} UTC [32m[ info][0m arg_3: 'THREE'
|
||||||
|
{datetime} UTC [32m[ info][0m arg_4: "FOUR"
|
||||||
|
{datetime} UTC [32m[ info][0m arg_5: OOOPS
|
||||||
|
{datetime} UTC [32m[ info][0m arg_6:
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-validation.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-validation.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
169
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-validation.stdio
generated
vendored
Normal file
169
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/main-usage-validation.stdio
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
ACCPTST:STDIO_REPLACE_DATETIMES
|
||||||
|
# complain about -3
|
||||||
|
|
||||||
|
Option -3 (--three) requires an argument
|
||||||
|
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
# complain about -4
|
||||||
|
|
||||||
|
Option -4 (--four) requires an argument
|
||||||
|
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
# complain about -5
|
||||||
|
|
||||||
|
Option -5 (--five) requires an argument
|
||||||
|
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
# complain about -8 (because -7 syntax is not supported)
|
||||||
|
|
||||||
|
Option -8 (--eight) requires an argument
|
||||||
|
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
# complain about -d (because -d syntax is not supported)
|
||||||
|
|
||||||
|
Option -d requires an argument
|
||||||
|
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
|
||||||
|
This is Bash3 Boilerplate's help text. Feel free to add any description of your
|
||||||
|
program or elaborate more on command-line arguments. This section is not
|
||||||
|
parsed and will be added as-is to the help.
|
||||||
|
|
||||||
|
# complain about nothing
|
||||||
|
{datetime} UTC [ info] arg_0: 0
|
||||||
|
{datetime} UTC [ info] arg_1: 0
|
||||||
|
{datetime} UTC [ info] arg_2: 0
|
||||||
|
{datetime} UTC [ info] arg_3: arg3
|
||||||
|
{datetime} UTC [ info] arg_4: arg4
|
||||||
|
{datetime} UTC [ info] arg_5: arg5
|
||||||
|
{datetime} UTC [ info] arg_6:
|
||||||
|
{datetime} UTC [ info] arg_7:
|
||||||
|
{datetime} UTC [ info] arg_8: arg8
|
||||||
|
{datetime} UTC [ info] arg_a: do-a
|
||||||
|
{datetime} UTC [ info] arg_b: do-b
|
||||||
|
{datetime} UTC [ info] arg_c: do-c
|
||||||
|
{datetime} UTC [ info] arg_d: argd
|
||||||
|
# test for issue #108
|
||||||
|
{datetime} UTC [ info] arg_0: 1
|
||||||
|
{datetime} UTC [ info] arg_1: 0
|
||||||
|
{datetime} UTC [ info] arg_2: 0
|
||||||
|
{datetime} UTC [ info] arg_3: arg3
|
||||||
|
{datetime} UTC [ info] arg_4: value
|
||||||
|
{datetime} UTC [ info] arg_5: arg5
|
||||||
|
{datetime} UTC [ info] arg_6:
|
||||||
|
{datetime} UTC [ info] arg_7:
|
||||||
|
{datetime} UTC [ info] arg_8: arg8
|
||||||
|
{datetime} UTC [ info] arg_a: do-a
|
||||||
|
{datetime} UTC [ info] arg_b: do-b
|
||||||
|
{datetime} UTC [ info] arg_c: do-c
|
||||||
|
{datetime} UTC [ info] arg_d: argd
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/megamount.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/megamount.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
2
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/megamount.stdio
generated
vendored
Normal file
2
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/megamount.stdio
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ERR: Unknown protocol: 'foobarfs://'
|
||||||
|
ERR: Unknown protocol: 'foobarfs://'
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/parse_url.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/parse_url.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
24
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/parse_url.stdio
generated
vendored
Normal file
24
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/parse_url.stdio
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
abc123
|
||||||
|
|
||||||
|
Use second argument to return just 1 variable.
|
||||||
|
parse_url() demo:
|
||||||
|
|
||||||
|
proto: http://
|
||||||
|
user: johndoe
|
||||||
|
pass: abc123
|
||||||
|
host: example.com
|
||||||
|
port: 8080
|
||||||
|
path: index.html
|
||||||
|
|
||||||
|
abc123
|
||||||
|
|
||||||
|
Use second argument to return just 1 variable.
|
||||||
|
parse_url() demo:
|
||||||
|
|
||||||
|
proto: http://
|
||||||
|
user: johndoe
|
||||||
|
pass: abc123
|
||||||
|
host: example.com
|
||||||
|
port: 8080
|
||||||
|
path: index.html
|
||||||
|
|
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/templater.exitcode
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/templater.exitcode
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
14
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/templater.stdio
generated
vendored
Normal file
14
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/fixture/templater.stdio
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
--
|
||||||
|
[connection]
|
||||||
|
host = 127.0.0.1
|
||||||
|
--
|
||||||
|
[connection]
|
||||||
|
host = 127.0.0.1
|
||||||
|
--
|
||||||
|
port = ${I_DONT_EXIST}
|
||||||
|
[connection]
|
||||||
|
host = 127.0.0.1
|
||||||
|
port = ${I_DONT_EXIST}
|
||||||
|
--
|
||||||
|
port = ${I_DONT_EXIST}
|
||||||
|
ERROR: Unable to replace the above template vars
|
15
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/double-source/run.sh
generated
vendored
Normal file
15
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/double-source/run.sh
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
export LOG_LEVEL=7
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
# shellcheck source=example.sh
|
||||||
|
source "${__root}/example.sh" -f /tmp/x
|
8
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/ini_val/data.ini
generated
vendored
Normal file
8
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/ini_val/data.ini
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[default]
|
||||||
|
orphan=exists
|
||||||
|
|
||||||
|
[connection]
|
||||||
|
host=127.0.0.1
|
||||||
|
|
||||||
|
[software]
|
||||||
|
packages=nginx, nodejs
|
54
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/ini_val/run.sh
generated
vendored
Executable file
54
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/ini_val/run.sh
generated
vendored
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
# Set magic variables for current FILE & DIR
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
# echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
|
||||||
|
# Use as standalone:
|
||||||
|
cp -f data.ini dummy.ini
|
||||||
|
echo "--> command: Read 3 values"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini orphan
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini connection.host
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini software.packages
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command
|
||||||
|
|
||||||
|
echo "--> command: Replace three values in-place and show result"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini orphan "no more"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini connection.host "192.168.0.1"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini software.packages "vim"
|
||||||
|
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command "commented" "this key is commented"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.new_command "commented too" "last addition will be moved downwards again after next command"
|
||||||
|
bash "${__root}/src/ini_val.sh" ./dummy.ini comment.command "works like a chame" "got this new comment"
|
||||||
|
cat dummy.ini
|
||||||
|
rm -f dummy.ini
|
||||||
|
|
||||||
|
# Use as include:
|
||||||
|
cp -f data.ini dummy.ini
|
||||||
|
|
||||||
|
# shellcheck source=main.sh
|
||||||
|
source "${__root}/src/ini_val.sh"
|
||||||
|
|
||||||
|
echo "--> function: Read 3 values"
|
||||||
|
ini_val ./dummy.ini orphan
|
||||||
|
ini_val ./dummy.ini connection.host
|
||||||
|
ini_val ./dummy.ini software.packages
|
||||||
|
ini_val ./dummy.ini comment.command
|
||||||
|
|
||||||
|
echo "--> function: Replace three values in-place and show result"
|
||||||
|
ini_val ./dummy.ini orphan "no more"
|
||||||
|
ini_val ./dummy.ini connection.host "192.168.0.1"
|
||||||
|
ini_val ./dummy.ini software.packages "vim"
|
||||||
|
|
||||||
|
ini_val ./dummy.ini comment.command "commented" "this key is commited"
|
||||||
|
ini_val ./dummy.ini comment.new_command "commented too" "last addition will be moved downwards again after next command"
|
||||||
|
ini_val ./dummy.ini comment.command "works like a chame" "got this new comment"
|
||||||
|
cat dummy.ini
|
||||||
|
rm -f dummy.ini
|
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-debug/run.sh
generated
vendored
Normal file
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-debug/run.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
env LOG_LEVEL=7 bash "${__root}/main.sh" -f /tmp/x
|
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-help/run.sh
generated
vendored
Executable file
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-help/run.sh
generated
vendored
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
bash "${__root}/main.sh" -f /tmp/x -h
|
16
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-longopt/run.sh
generated
vendored
Normal file
16
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-longopt/run.sh
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# set -o pipefail
|
||||||
|
# set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
(
|
||||||
|
env LOG_LEVEL=6 bash "${__root}/main.sh" --file /tmp/x;
|
||||||
|
env LOG_LEVEL=6 bash "${__root}/main.sh" --file=/tmp/x;
|
||||||
|
env LOG_LEVEL=6 bash "${__root}/main.sh" -f /tmp/x
|
||||||
|
) 2>&1 |grep arg_f
|
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-nocolor/run.sh
generated
vendored
Normal file
12
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-nocolor/run.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
env LOG_LEVEL=7 NO_COLOR=true bash "${__root}/main.sh" -f /tmp/x
|
19
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-repeated/run.sh
generated
vendored
Normal file
19
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-repeated/run.sh
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# set -o pipefail
|
||||||
|
# set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
(
|
||||||
|
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -f dummy -i simple_input -i "input_in_quotes" -i "input with spaces" -i "input with \"quotes\"" -i last_input
|
||||||
|
) 2>&1 |grep arg_i -A 5
|
||||||
|
|
||||||
|
(
|
||||||
|
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -x -f dummy -x -x
|
||||||
|
env LOG_LEVEL="${LOG_LEVEL:-6}" bash "${__root}/main.sh" -f dummy -xxxx
|
||||||
|
) 2>&1 |grep arg_x
|
32
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-usage-defaults/run.sh
generated
vendored
Executable file
32
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-usage-defaults/run.sh
generated
vendored
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
-1 --one Do one thing. Default="ONE"
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More description. Default="TWO"
|
||||||
|
-3 --three [arg] Do three things. Default="'THREE'"
|
||||||
|
More description.
|
||||||
|
-4 --four [arg] Do four things.
|
||||||
|
More description. Default='"FOUR"'
|
||||||
|
-5 --five [arg] Do five things. Default="FIVE"
|
||||||
|
More description. Default='OOOPS'
|
||||||
|
-6 --six [arg] Do six things.
|
||||||
|
More description.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
export __usage
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
# shellcheck source=main.sh
|
||||||
|
source "${__root}/main.sh"
|
||||||
|
|
||||||
|
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
64
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-usage-validation/run.sh
generated
vendored
Executable file
64
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/main-usage-validation/run.sh
generated
vendored
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck source=main.sh
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
|
||||||
|
-0 --zero Do nothing.
|
||||||
|
-1 --one Do one thing. Required.
|
||||||
|
More description.
|
||||||
|
-2 --two Do two things.
|
||||||
|
More. Required. Description.
|
||||||
|
-3 --three [arg] Do three things.
|
||||||
|
Required.
|
||||||
|
-4 --four {arg} Do four things.
|
||||||
|
-5 --five {arg} Do five things. Required. Maybe.
|
||||||
|
-6 --six [arg] Do six things. Not Required.
|
||||||
|
Required, it is not.
|
||||||
|
-7 --seven [arg] Required. Or bust.
|
||||||
|
-8 --eight [arg] Do eight things.
|
||||||
|
More.Required.Description.
|
||||||
|
-a [arg] Do A. Required.
|
||||||
|
Default="do-a"
|
||||||
|
-b {arg} Do B.Default="do-b"
|
||||||
|
-c [arg] Required. Default="do-c"
|
||||||
|
-d {arg} Default="do-d"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
export __usage
|
||||||
|
export NO_COLOR="true"
|
||||||
|
|
||||||
|
echo "ACCPTST:STDIO_REPLACE_DATETIMES"
|
||||||
|
|
||||||
|
echo "# complain about -3"
|
||||||
|
(source "${__root}/main.sh") || true
|
||||||
|
|
||||||
|
echo "# complain about -4"
|
||||||
|
(source "${__root}/main.sh" -3 arg3) || true
|
||||||
|
|
||||||
|
echo "# complain about -5"
|
||||||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4) || true
|
||||||
|
|
||||||
|
echo "# complain about -8 (because -7 syntax is not supported)"
|
||||||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5) || true
|
||||||
|
|
||||||
|
echo "# complain about -d (because -d syntax is not supported)"
|
||||||
|
(source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8) || true
|
||||||
|
|
||||||
|
echo "# complain about nothing"
|
||||||
|
(
|
||||||
|
source "${__root}/main.sh" -3 arg3 -4 arg4 -5 arg5 -8 arg8 -d argd
|
||||||
|
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "# test for issue #108"
|
||||||
|
(
|
||||||
|
source "${__root}/main.sh" -3 arg3 -5 arg5 -8 arg8 -d argd --four value --zero
|
||||||
|
for argument in ${!arg_*}; do info "${argument}: ${!argument}"; done
|
||||||
|
)
|
21
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/megamount/run.sh
generated
vendored
Normal file
21
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/megamount/run.sh
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
__sysTmpDir="${TMPDIR:-/tmp}"
|
||||||
|
__sysTmpDir="${__sysTmpDir%/}" # <-- remove trailing slash on macosx
|
||||||
|
|
||||||
|
# Currently I only know how to test a failing condition here since
|
||||||
|
# it's too invasive to create actual mounts to play with on a system
|
||||||
|
|
||||||
|
bash "${__root}/src/megamount.sh" 'foobarfs://janedoe:abc123@192.168.0.1/documents' "${__sysTmpDir}/mnt/documents" || true
|
||||||
|
|
||||||
|
# shellcheck source=src/megamount.sh
|
||||||
|
source "${__root}/src/megamount.sh"
|
||||||
|
|
||||||
|
megamount 'foobarfs://janedoe:abc123@192.168.0.1/documents' "${__sysTmpDir}/mnt/documents"
|
17
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/parse_url/run.sh
generated
vendored
Normal file
17
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/parse_url/run.sh
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
bash "${__root}/src/parse_url.sh" 'http://johndoe:abc123@example.com:8080/index.html' pass
|
||||||
|
bash "${__root}/src/parse_url.sh" 'http://johndoe:abc123@example.com:8080/index.html'
|
||||||
|
|
||||||
|
# shellcheck source=src/parse_url.sh
|
||||||
|
source "${__root}/src/parse_url.sh"
|
||||||
|
|
||||||
|
parse_url 'http://johndoe:abc123@example.com:8080/index.html' pass
|
||||||
|
parse_url 'http://johndoe:abc123@example.com:8080/index.html'
|
2
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/app.template.cfg
generated
vendored
Normal file
2
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/app.template.cfg
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[connection]
|
||||||
|
host = ${TARGET_HOST}
|
3
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/break.template.cfg
generated
vendored
Normal file
3
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/break.template.cfg
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[connection]
|
||||||
|
host = ${TARGET_HOST}
|
||||||
|
port = ${I_DONT_EXIST}
|
36
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/run.sh
generated
vendored
Normal file
36
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/scenario/templater/run.sh
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o pipefail
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
# set -o xtrace
|
||||||
|
|
||||||
|
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
__base="$(basename "${__file}" .sh)"
|
||||||
|
|
||||||
|
__root="$(cd "$(dirname "$(dirname "$(dirname "${__dir}")")")" && pwd)"
|
||||||
|
|
||||||
|
__templaterTmpFile=$(mktemp "${TMPDIR:-/tmp}/${__base}.XXXXXX")
|
||||||
|
function cleanup_before_exit () { rm "${__templaterTmpFile:?}"; }
|
||||||
|
trap cleanup_before_exit EXIT
|
||||||
|
|
||||||
|
echo "--"
|
||||||
|
env TARGET_HOST="127.0.0.1" bash "${__root}/src/templater.sh" ./app.template.cfg "${__templaterTmpFile}"
|
||||||
|
cat "${__templaterTmpFile}"
|
||||||
|
|
||||||
|
echo "--"
|
||||||
|
export TARGET_HOST="127.0.0.1"
|
||||||
|
|
||||||
|
# shellcheck source=src/templater.sh
|
||||||
|
source "${__root}/src/templater.sh"
|
||||||
|
|
||||||
|
templater ./app.template.cfg "${__templaterTmpFile}"
|
||||||
|
cat "${__templaterTmpFile}"
|
||||||
|
|
||||||
|
echo "--"
|
||||||
|
env ALLOW_REMAINDERS="1" TARGET_HOST="127.0.0.1" bash "${__root}/src/templater.sh" ./break.template.cfg "${__templaterTmpFile}"
|
||||||
|
cat "${__templaterTmpFile}"
|
||||||
|
|
||||||
|
echo "--"
|
||||||
|
env TARGET_HOST="127.0.0.1" bash "${__root}/src/templater.sh" ./break.template.cfg "${__templaterTmpFile}"
|
||||||
|
cat "${__templaterTmpFile}"
|
45
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/style.pl
generated
vendored
Executable file
45
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/test/style.pl
generated
vendored
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
die "usage: $0 <file>\n" if (not @ARGV);
|
||||||
|
|
||||||
|
my $rc = 0;
|
||||||
|
my $file = shift;
|
||||||
|
|
||||||
|
open(my $fh, '<', $file) or die "Cannot open \`$file' for read: $!\n";
|
||||||
|
while (<$fh>) {
|
||||||
|
next if (/^\s*#/);
|
||||||
|
|
||||||
|
my $errors = 0;
|
||||||
|
|
||||||
|
# remove everything between single quotes
|
||||||
|
# this will remove too much in case of: echo "var='$var'"
|
||||||
|
# and thus miss an opportunity to complain later on
|
||||||
|
# also it mangles the input line irreversible
|
||||||
|
s/'[^']+'/'___'/g;
|
||||||
|
|
||||||
|
# highlight unbraced variables--
|
||||||
|
# unless properly backslash'ed
|
||||||
|
$errors += s/((?:^|[^\\]))(((\\\\)+)?\$\w)/$1\033[31m$2\033[0m/g;
|
||||||
|
|
||||||
|
# highlight single square brackets
|
||||||
|
$errors += s/((?:^|\s+))\[([^\[].+[^\]])\](\s*(;|&&|\|\|))/$1\033[31m\[\033[0m$2\033[31m\]\033[0m$3/g;
|
||||||
|
|
||||||
|
# highlight double equal sign
|
||||||
|
$errors += s/(\[\[.*)(==)(.*\]\])/$1\033[31m$2\033[0m$3/g;
|
||||||
|
|
||||||
|
# highlight tabs mixed with whitespace at beginning of lines
|
||||||
|
$errors += s/^( *)(\t+ *)/\033[31m\[$2\]\033[0m/;
|
||||||
|
|
||||||
|
# highlight trailing whitespace
|
||||||
|
$errors += s/([ \t]+)$/\033[31m\[$1\]\033[0m/;
|
||||||
|
|
||||||
|
next if (not $errors);
|
||||||
|
print "${file}[$.]: $_";
|
||||||
|
$rc = 1;
|
||||||
|
}
|
||||||
|
close($fh);
|
||||||
|
|
||||||
|
exit $rc;
|
1372
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/yarn.lock
generated
vendored
Normal file
1372
vendor/git.knownelement.com/ExternalVendorCode/bash3boilerplate/yarn.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
168
vendor/git.knownelement.com/ExternalVendorCode/mo/.eslintrc.yaml
generated
vendored
Normal file
168
vendor/git.knownelement.com/ExternalVendorCode/mo/.eslintrc.yaml
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
parserOptions:
|
||||||
|
ecmaVersion: latest
|
||||||
|
sourceType: module
|
||||||
|
env:
|
||||||
|
es6: true
|
||||||
|
jasmine: true
|
||||||
|
node: true
|
||||||
|
extends: eslint:recommended
|
||||||
|
rules:
|
||||||
|
accessor-pairs: error
|
||||||
|
array-bracket-spacing:
|
||||||
|
- error
|
||||||
|
- never
|
||||||
|
array-callback-return: error
|
||||||
|
block-spacing:
|
||||||
|
- error
|
||||||
|
- never
|
||||||
|
brace-style: error
|
||||||
|
comma-dangle: error
|
||||||
|
comma-spacing: error
|
||||||
|
comma-style: error
|
||||||
|
complexity:
|
||||||
|
- error
|
||||||
|
- 10
|
||||||
|
computed-property-spacing: error
|
||||||
|
consistent-return: error
|
||||||
|
consistent-this: error
|
||||||
|
constructor-super: error
|
||||||
|
curly: error
|
||||||
|
default-case: error
|
||||||
|
dot-notation: error
|
||||||
|
eol-last: error
|
||||||
|
eqeqeq: error
|
||||||
|
generator-star-spacing: error
|
||||||
|
global-require: off
|
||||||
|
guard-for-in: error
|
||||||
|
jsx-quotes: error
|
||||||
|
key-spacing: error
|
||||||
|
keyword-spacing: error
|
||||||
|
linebreak-style: error
|
||||||
|
lines-around-comment:
|
||||||
|
- error
|
||||||
|
-
|
||||||
|
allowBlockStart: true
|
||||||
|
allowObjectStart: true
|
||||||
|
allowArrayStart: true
|
||||||
|
max-statements-per-line: error
|
||||||
|
new-cap: error
|
||||||
|
new-parens: error
|
||||||
|
no-array-constructor: error
|
||||||
|
no-bitwise: error
|
||||||
|
no-caller: error
|
||||||
|
no-case-declarations: error
|
||||||
|
no-catch-shadow: error
|
||||||
|
no-class-assign: error
|
||||||
|
no-cond-assign: error
|
||||||
|
no-confusing-arrow: error
|
||||||
|
no-console: off
|
||||||
|
no-const-assign: error
|
||||||
|
no-constant-condition: error
|
||||||
|
no-continue: error
|
||||||
|
no-delete-var: error
|
||||||
|
no-dupe-args: error
|
||||||
|
no-dupe-class-members: error
|
||||||
|
no-dupe-keys: error
|
||||||
|
no-duplicate-case: error
|
||||||
|
no-duplicate-imports: error
|
||||||
|
no-empty: off
|
||||||
|
no-empty-character-class: error
|
||||||
|
no-empty-pattern: error
|
||||||
|
no-eq-null: error
|
||||||
|
no-eval: error
|
||||||
|
no-extend-native: error
|
||||||
|
no-extra-bind: error
|
||||||
|
no-extra-boolean-cast: error
|
||||||
|
no-extra-label: error
|
||||||
|
no-extra-semi: error
|
||||||
|
no-fallthrough: error
|
||||||
|
no-func-assign: error
|
||||||
|
no-implied-eval: error
|
||||||
|
no-inner-declarations: error
|
||||||
|
no-invalid-this: error
|
||||||
|
no-invalid-regexp: error
|
||||||
|
no-irregular-whitespace: error
|
||||||
|
no-iterator: error
|
||||||
|
no-label-var: error
|
||||||
|
no-labels: error
|
||||||
|
no-lone-blocks: error
|
||||||
|
no-lonely-if: error
|
||||||
|
no-loop-func: error
|
||||||
|
no-mixed-spaces-and-tabs: error
|
||||||
|
no-multi-spaces: error
|
||||||
|
no-multi-str: error
|
||||||
|
no-multiple-empty-lines:
|
||||||
|
- error
|
||||||
|
-
|
||||||
|
max: 2
|
||||||
|
no-native-reassign: error
|
||||||
|
no-negated-condition: error
|
||||||
|
no-nested-ternary: error
|
||||||
|
no-new: error
|
||||||
|
no-new-func: error
|
||||||
|
no-new-object: error
|
||||||
|
no-new-symbol: error
|
||||||
|
no-new-wrappers: error
|
||||||
|
no-obj-calls: error
|
||||||
|
no-octal: error
|
||||||
|
no-octal-escape: error
|
||||||
|
no-path-concat: error
|
||||||
|
no-plusplus: error
|
||||||
|
no-proto: error
|
||||||
|
no-redeclare: error
|
||||||
|
no-regex-spaces: error
|
||||||
|
no-restricted-globals: error
|
||||||
|
no-return-assign: error
|
||||||
|
no-script-url: error
|
||||||
|
no-self-assign: error
|
||||||
|
no-self-compare: error
|
||||||
|
no-sequences: error
|
||||||
|
no-shadow: error
|
||||||
|
no-shadow-restricted-names: error
|
||||||
|
no-spaced-func: error
|
||||||
|
no-sparse-arrays: error
|
||||||
|
no-this-before-super: error
|
||||||
|
no-throw-literal: error
|
||||||
|
no-trailing-spaces: error
|
||||||
|
no-undef: error
|
||||||
|
no-undef-init: error
|
||||||
|
no-unexpected-multiline: error
|
||||||
|
no-unmodified-loop-condition: error
|
||||||
|
no-unneeded-ternary: error
|
||||||
|
no-unreachable: error
|
||||||
|
no-unsafe-finally: error
|
||||||
|
no-unused-expressions: error
|
||||||
|
no-unused-labels: error
|
||||||
|
no-unused-vars: error
|
||||||
|
no-useless-call: error
|
||||||
|
no-useless-computed-key: error
|
||||||
|
no-useless-concat: error
|
||||||
|
no-useless-constructor: error
|
||||||
|
no-useless-escape: error
|
||||||
|
no-void: error
|
||||||
|
no-warning-comments: warn
|
||||||
|
no-whitespace-before-property: error
|
||||||
|
no-with: error
|
||||||
|
operator-assignment: error
|
||||||
|
padded-blocks:
|
||||||
|
- error
|
||||||
|
- never
|
||||||
|
prefer-const: error
|
||||||
|
quote-props:
|
||||||
|
- error
|
||||||
|
- as-needed
|
||||||
|
radix: error
|
||||||
|
require-yield: error
|
||||||
|
semi: error
|
||||||
|
semi-spacing: error
|
||||||
|
space-before-blocks: error
|
||||||
|
space-in-parens: error
|
||||||
|
space-infix-ops:
|
||||||
|
- error
|
||||||
|
-
|
||||||
|
int32Hint: false
|
||||||
|
space-unary-ops: error
|
||||||
|
spaced-comment: error
|
||||||
|
use-isnan: error
|
||||||
|
valid-typeof: error
|
||||||
|
yield-star-spacing: error
|
13
vendor/git.knownelement.com/ExternalVendorCode/mo/.github/workflows/ci.yaml
generated
vendored
Normal file
13
vendor/git.knownelement.com/ExternalVendorCode/mo/.github/workflows/ci.yaml
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name: CI
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Run tests
|
||||||
|
run: ./run-tests
|
||||||
|
- name: Run against spec
|
||||||
|
run: ./run-spec
|
45
vendor/git.knownelement.com/ExternalVendorCode/mo/.github/workflows/release.yaml
generated
vendored
Normal file
45
vendor/git.knownelement.com/ExternalVendorCode/mo/.github/workflows/release.yaml
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
name: docker push
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: Docker meta
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tag-match: v(.*)
|
||||||
|
- name: Set up QEMU
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Cache Docker layers
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
push: true
|
9
vendor/git.knownelement.com/ExternalVendorCode/mo/.gitignore
generated
vendored
Normal file
9
vendor/git.knownelement.com/ExternalVendorCode/mo/.gitignore
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
*.swp
|
||||||
|
diagnostic.partial
|
||||||
|
diagnostic.test
|
||||||
|
tests/*.diff
|
||||||
|
spec/
|
||||||
|
spec-runner/
|
||||||
|
node_modules/
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
616
vendor/git.knownelement.com/ExternalVendorCode/mo/API.md
generated
vendored
Normal file
616
vendor/git.knownelement.com/ExternalVendorCode/mo/API.md
generated
vendored
Normal file
@ -0,0 +1,616 @@
|
|||||||
|
API / Function Documentation
|
||||||
|
============================
|
||||||
|
|
||||||
|
This documentation is generated automatically from the source of [mo] thanks to [tomdoc.sh].
|
||||||
|
|
||||||
|
|
||||||
|
`mo()`
|
||||||
|
------
|
||||||
|
|
||||||
|
Public: Template parser function. Writes templates to stdout.
|
||||||
|
|
||||||
|
* $0 - Name of the mo file, used for getting the help message.
|
||||||
|
* $@ - Filenames to parse.
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::debug()`
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Internal: Show a debug message
|
||||||
|
|
||||||
|
* $1 - The debug message to show
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::debugShowState()`
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Internal: Show a debug message and internal state information
|
||||||
|
|
||||||
|
No arguments
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::error()`
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Internal: Show an error message and exit
|
||||||
|
|
||||||
|
* $1 - The error message to show
|
||||||
|
* $2 - Error code
|
||||||
|
|
||||||
|
Returns nothing. Exits the program.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::errorNear()`
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Internal: Show an error message with a snippet of context and exit
|
||||||
|
|
||||||
|
* $1 - The error message to show
|
||||||
|
* $2 - The starting point
|
||||||
|
* $3 - Error code
|
||||||
|
|
||||||
|
Returns nothing. Exits the program.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::usage()`
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Internal: Displays the usage for mo. Pulls this from the file that contained the `mo` function. Can only work when the right filename comes is the one argument, and that only happens when `mo` is called with `$0` set to this file.
|
||||||
|
|
||||||
|
* $1 - Filename that has the help message
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::content()`
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Internal: Fetches the content to parse into MO_UNPARSED. Can be a list of partials for files or the content from stdin.
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2-@ - File names (optional), read from stdin otherwise
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::contentFile()`
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Internal: Read a file into MO_UNPARSED.
|
||||||
|
|
||||||
|
* $1 - Destination variable name.
|
||||||
|
* $2 - Filename to load - if empty, defaults to /dev/stdin
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::indirect()`
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Internal: Send a variable up to the parent of the caller of this function.
|
||||||
|
|
||||||
|
* $1 - Variable name
|
||||||
|
* $2 - Value
|
||||||
|
|
||||||
|
Examples
|
||||||
|
|
||||||
|
callFunc () {
|
||||||
|
local "$1" && mo::indirect "$1" "the value"
|
||||||
|
}
|
||||||
|
callFunc dest
|
||||||
|
echo "$dest" # writes "the value"
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::indirectArray()`
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Internal: Send an array as a variable up to caller of a function
|
||||||
|
|
||||||
|
* $1 - Variable name
|
||||||
|
* $2-@ - Array elements
|
||||||
|
|
||||||
|
Examples
|
||||||
|
|
||||||
|
callFunc () {
|
||||||
|
local myArray=(one two three)
|
||||||
|
local "$1" && mo::indirectArray "$1" "${myArray[@]}"
|
||||||
|
}
|
||||||
|
callFunc dest
|
||||||
|
echo "${dest[@]}" # writes "one two three"
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::trimUnparsed()`
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Internal: Trim leading characters from MO_UNPARSED
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::chomp()`
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Internal: Remove whitespace and content after whitespace
|
||||||
|
|
||||||
|
* $1 - Name of the destination variable
|
||||||
|
* $2 - The string to chomp
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parse()`
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Public: Parses text, interpolates mustache tags. Utilizes the current value of MO_OPEN_DELIMITER, MO_CLOSE_DELIMITER, and MO_STANDALONE_CONTENT. Those three variables shouldn't be changed by user-defined functions.
|
||||||
|
|
||||||
|
* $1 - Destination variable name - where to store the finished content
|
||||||
|
* $2 - Content to parse
|
||||||
|
* $3 - Preserve standalone status/content - truthy if not empty. When set to a value, that becomes the standalone content value
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseInternal()`
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Internal: Parse MO_UNPARSED, writing content to MO_PARSED. Interpolates mustache tags.
|
||||||
|
|
||||||
|
No arguments
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseBlock()`
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a block
|
||||||
|
|
||||||
|
* $1 - Invert condition ("true" or "false")
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseBlockFunction()`
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a block whose first argument is a function
|
||||||
|
|
||||||
|
* $1 - Invert condition ("true" or "false")
|
||||||
|
* $2-@ - The parsed tokens from inside the block tags
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseBlockArray()`
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a block whose first argument is an array
|
||||||
|
|
||||||
|
* $1 - Invert condition ("true" or "false")
|
||||||
|
* $2-@ - The parsed tokens from inside the block tags
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseBlockValue()`
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a block whose first argument is a value
|
||||||
|
|
||||||
|
* $1 - Invert condition ("true" or "false")
|
||||||
|
* $2-@ - The parsed tokens from inside the block tags
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parsePartial()`
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a partial
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Indentation will be applied to the entire partial's contents before parsing. This indentation is based on the whitespace that ends the previously parsed content.
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseComment()`
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing a comment
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseDelimiter()`
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing the change of delimiters
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::parseValue()`
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Internal: Handle parsing value or function call
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::isFunction()`
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Internal: Determine if the given name is a defined function.
|
||||||
|
|
||||||
|
* $1 - Function name to check
|
||||||
|
|
||||||
|
Be extremely careful. Even if strict mode is enabled, it is not honored in newer versions of Bash. Any errors that crop up here will not be caught automatically.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
|
||||||
|
moo () {
|
||||||
|
echo "This is a function"
|
||||||
|
}
|
||||||
|
if mo::isFunction moo; then
|
||||||
|
echo "moo is a defined function"
|
||||||
|
fi
|
||||||
|
|
||||||
|
Returns 0 if the name is a function, 1 otherwise.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::isArray()`
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Internal: Determine if a given environment variable exists and if it is an array.
|
||||||
|
|
||||||
|
* $1 - Name of environment variable
|
||||||
|
|
||||||
|
Be extremely careful. Even if strict mode is enabled, it is not honored in newer versions of Bash. Any errors that crop up here will not be caught automatically.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
|
||||||
|
var=(abc)
|
||||||
|
if moIsArray var; then
|
||||||
|
echo "This is an array"
|
||||||
|
echo "Make sure you don't accidentally use \$var"
|
||||||
|
fi
|
||||||
|
|
||||||
|
Returns 0 if the name is not empty, 1 otherwise.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::isArrayIndexValid()`
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Internal: Determine if an array index exists.
|
||||||
|
|
||||||
|
* $1 - Variable name to check
|
||||||
|
* $2 - The index to check
|
||||||
|
|
||||||
|
Has to check if the variable is an array and if the index is valid for that type of array.
|
||||||
|
|
||||||
|
Returns true (0) if everything was ok, 1 if there's any condition that fails.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::isVarSet()`
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Internal: Determine if a variable is assigned, even if it is assigned an empty value.
|
||||||
|
|
||||||
|
* $1 - Variable name to check.
|
||||||
|
|
||||||
|
Can not use logic like this in case invalid variable names are passed. [[ "${!1-a}" == "${!1-b}" ]]
|
||||||
|
|
||||||
|
Returns true (0) if the variable is set, 1 if the variable is unset.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::isTruthy()`
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Internal: Determine if a value is considered truthy.
|
||||||
|
|
||||||
|
* $1 - The value to test
|
||||||
|
* $2 - Invert the value, either "true" or "false"
|
||||||
|
|
||||||
|
Returns true (0) if truthy, 1 otherwise.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluate()`
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Internal: Convert token list to values
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2-@ - Tokens to convert
|
||||||
|
|
||||||
|
Sample call:
|
||||||
|
|
||||||
|
mo::evaluate dest NAME username VALUE abc123 PAREN 2
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluateListOfSingles()`
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Internal: Convert an argument list to individual values.
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2-@ - A list of argument types and argument name/value.
|
||||||
|
|
||||||
|
This assumes each value is separate from the rest. In contrast, mo::evaluate will pass all arguments to a function if the first value is a function.
|
||||||
|
|
||||||
|
Sample call:
|
||||||
|
|
||||||
|
mo::evaluateListOfSingles dest NAME username VALUE abc123
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluateSingle()`
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Internal: Evaluate a single argument
|
||||||
|
|
||||||
|
* $1 - Name of variable for result
|
||||||
|
* $2 - Type of argument, either NAME or VALUE
|
||||||
|
* $3 - Argument
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluateKey()`
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Internal: Return the value for @key based on current's name
|
||||||
|
|
||||||
|
* $1 - Name of variable for result
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluateVariable()`
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Internal: Handle a variable name
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2 - Variable name
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::findVariableName()`
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Internal: Find the name of a variable to use
|
||||||
|
|
||||||
|
* $1 - Destination variable name, receives an array
|
||||||
|
* $2 - Variable name from the template
|
||||||
|
|
||||||
|
The array contains the following values
|
||||||
|
* [0] - Variable name
|
||||||
|
* [1] - Array index, or empty string
|
||||||
|
|
||||||
|
Example variables a="a"
|
||||||
|
b="b"
|
||||||
|
c=("c.0" "c.1")
|
||||||
|
d=([b]="d.b" [d]="d.d")
|
||||||
|
|
||||||
|
Given these inputs (function input, current value), produce these outputs a c => a
|
||||||
|
a c.0 => a
|
||||||
|
b d => d.b
|
||||||
|
b d.d => d.b
|
||||||
|
a d => d.a
|
||||||
|
a d.d => d.a
|
||||||
|
c.0 d => c.0
|
||||||
|
d.b d => d.b
|
||||||
|
'' c => c
|
||||||
|
'' c.0 => c.0
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::join()`
|
||||||
|
------------
|
||||||
|
|
||||||
|
Internal: Join / implode an array
|
||||||
|
|
||||||
|
* $1 - Variable name to receive the joined content
|
||||||
|
* $2 - Joiner
|
||||||
|
* $3-@ - Elements to join
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::evaluateFunction()`
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Internal: Call a function.
|
||||||
|
|
||||||
|
* $1 - Variable for output
|
||||||
|
* $2 - Content to pass
|
||||||
|
* $3 - Function to call
|
||||||
|
* $4-@ - Additional arguments as list of type, value/name
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::standaloneCheck()`
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Internal: Check if a tag appears to have only whitespace before it and after it on a line. There must be a new line before and there must be a newline after or the end of a string
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Returns 0 if this is a standalone tag, 1 otherwise.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::standaloneProcess()`
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Internal: Process content before and after a tag. Remove prior whitespace up to the previous newline. Remove following whitespace up to and including the next newline.
|
||||||
|
|
||||||
|
No arguments.
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::indentLines()`
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Internal: Apply indentation before any line that has content in MO_UNPARSED.
|
||||||
|
|
||||||
|
* $1 - Destination variable name.
|
||||||
|
* $2 - The indentation string.
|
||||||
|
* $3 - The content that needs the indentation string prepended on each line.
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::escape()`
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Internal: Escape a value
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2 - Value to escape
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::getContentUntilClose()`
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Internal: Get the content up to the end of the block by minimally parsing and balancing blocks. Returns the content before the end tag to the caller and removes the content + the end tag from MO_UNPARSED. This can change the delimiters, adjusting MO_OPEN_DELIMITER and MO_CLOSE_DELIMITER.
|
||||||
|
|
||||||
|
* $1 - Destination variable name
|
||||||
|
* $2 - Token string to match for a closing tag
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::tokensToString()`
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Internal: Convert a list of tokens to a string
|
||||||
|
|
||||||
|
* $1 - Destination variable for the string
|
||||||
|
* $2-$@ - Token list
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::getContentTrim()`
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Internal: Trims content from MO_UNPARSED, returns trimmed content.
|
||||||
|
|
||||||
|
* $1 - Destination variable
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::getContentComment()`
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Get the content up to and including a close tag
|
||||||
|
|
||||||
|
* $1 - Destination variable
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::getContentDelimiter()`
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Get the content up to and including a close tag. First two non-whitespace tokens become the new open and close tag.
|
||||||
|
|
||||||
|
* $1 - Destination variable
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::getContentWithinTag()`
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Get the content up to and including a close tag. First two non-whitespace tokens become the new open and close tag.
|
||||||
|
|
||||||
|
* $1 - Destination variable, an array
|
||||||
|
* $2 - Terminator string
|
||||||
|
|
||||||
|
The array contents: [0] The raw content within the tag
|
||||||
|
[1] The parsed tokens as a single string
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::tokenizeTagContents()`
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Internal: Parse MO_UNPARSED and retrieve the content within the tag delimiters. Converts everything into an array of string values.
|
||||||
|
|
||||||
|
* $1 - Destination variable for the array of contents.
|
||||||
|
* $2 - Stop processing when this content is found.
|
||||||
|
|
||||||
|
The list of tokens are in RPN form. The first item in the resulting array is the number of actual tokens (after combining command tokens) in the list.
|
||||||
|
|
||||||
|
Given: a 'bc' "de\"\n" (f {g 'h'}) Result: ([0]=4 [1]=NAME [2]=a [3]=VALUE [4]=bc [5]=VALUE [6]=$'de\"\n' [7]=NAME [8]=f [9]=NAME [10]=g [11]=VALUE [12]=h [13]=BRACE [14]=2 [15]=PAREN [16]=2
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::tokenizeTagContentsName()`
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
Internal: Get the contents of a variable name.
|
||||||
|
|
||||||
|
* $1 - Destination variable name for the token list (array of strings)
|
||||||
|
|
||||||
|
Returns nothing
|
||||||
|
|
||||||
|
|
||||||
|
`mo::tokenizeTagContentsDoubleQuote()`
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Internal: Get the contents of a tag in double quotes. Parses the backslash sequences.
|
||||||
|
|
||||||
|
* $1 - Destination variable name for the token list (array of strings)
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`mo::tokenizeTagContentsSingleQuote()`
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Internal: Get the contents of a tag in single quotes. Only gets the raw value.
|
||||||
|
|
||||||
|
* $1 - Destination variable name for the token list (array of strings)
|
||||||
|
|
||||||
|
Returns nothing.
|
||||||
|
|
||||||
|
|
||||||
|
`MO_ORIGINAL_COMMAND`
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Save the original command's path for usage later
|
||||||
|
|
||||||
|
|
||||||
|
[mo]: ./mo
|
||||||
|
[tomdoc.sh]: https://github.com/tests-always-included/tomdoc.sh
|
7
vendor/git.knownelement.com/ExternalVendorCode/mo/Dockerfile
generated
vendored
Normal file
7
vendor/git.knownelement.com/ExternalVendorCode/mo/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache bash
|
||||||
|
ADD mo /usr/local/bin/mo
|
||||||
|
RUN chmod +x /usr/local/bin/mo
|
||||||
|
|
||||||
|
ENTRYPOINT /usr/local/bin/mo
|
7
vendor/git.knownelement.com/ExternalVendorCode/mo/LICENSE.md
generated
vendored
Normal file
7
vendor/git.knownelement.com/ExternalVendorCode/mo/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.
|
||||||
|
|
||||||
|
The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by contributors", in the same place and form as other third-party acknowledgments. Alternately, this acknowledgment may appear in the software itself, in the same form and location as other such third-party acknowledgments.
|
340
vendor/git.knownelement.com/ExternalVendorCode/mo/README.md
generated
vendored
Normal file
340
vendor/git.knownelement.com/ExternalVendorCode/mo/README.md
generated
vendored
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
Mo - Mustache Templates in Bash
|
||||||
|
===============================
|
||||||
|
|
||||||
|
[Mustache] templates are simple, logic-less templates. Because of their simplicity, they are able to be ported to many languages. The syntax is quite simple.
|
||||||
|
|
||||||
|
Hello, {{NAME}}.
|
||||||
|
|
||||||
|
I hope your {{TIME_PERIOD}} was fun.
|
||||||
|
|
||||||
|
The above file is [`demo/fun-trip.mo`](demo/fun-trip.mo). Let's try using this template some data from bash's environment. Go to your checked out copy of the project and run a command like this:
|
||||||
|
|
||||||
|
NAME=Tyler TIME_PERIOD=weekend ./mo demo/fun-trip.mo
|
||||||
|
|
||||||
|
Your result?
|
||||||
|
|
||||||
|
Hello, Tyler.
|
||||||
|
|
||||||
|
I hope your weekend was fun.
|
||||||
|
|
||||||
|
This bash version supports conditionals, functions (both as filters and as values), as well as indexed arrays (for iteration). You are able to leverage these additional features by adding more information into the environment. It is easiest to do this when you source `mo`. See the [demo scripts](demo/) for further examples.
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Bash 3.x (the aim is to make it work on Macs)
|
||||||
|
* The "coreutils" package (`basename` and `cat`)
|
||||||
|
* ... that's it. Why? Because bash **can**!
|
||||||
|
|
||||||
|
If you intend to develop this and run the official specs, you also need node.js.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
There are a few ways you can install this tool. How you install it depends on how you want to use it.
|
||||||
|
|
||||||
|
|
||||||
|
### Globally; For Everyone
|
||||||
|
|
||||||
|
You can install this file in `/usr/local/bin/` or `/usr/bin/` by simply downloading it, changing the permissions, then moving it to the right location. Double check that your system's PATH includes the destination folder, otherwise users may have a hard time starting the command.
|
||||||
|
|
||||||
|
# Download
|
||||||
|
curl -sSL https://raw.githubusercontent.com/tests-always-included/mo/master/mo -o mo
|
||||||
|
|
||||||
|
# Make executable
|
||||||
|
chmod +x mo
|
||||||
|
|
||||||
|
# Move to the right folder
|
||||||
|
sudo mv mo /usr/local/bin/
|
||||||
|
|
||||||
|
# Test
|
||||||
|
echo "works" | mo
|
||||||
|
|
||||||
|
|
||||||
|
### Locally; For Yourself
|
||||||
|
|
||||||
|
This is very similar to installing it globally but it does not require root privileges. It is very important that your PATH includes the destination folder otherwise it won't work. Some local folders that are typically used are `~/bin/` and `~/.local/bin/`.
|
||||||
|
|
||||||
|
# Download
|
||||||
|
curl -sSL https://raw.githubusercontent.com/tests-always-included/mo/master/mo -o mo
|
||||||
|
|
||||||
|
# Make executable
|
||||||
|
chmod +x mo
|
||||||
|
|
||||||
|
# Ensure destination folder exists
|
||||||
|
mkdir -p ~/.local/bin/
|
||||||
|
|
||||||
|
# Move to the right folder
|
||||||
|
mv mo ~/.local/bin/
|
||||||
|
|
||||||
|
# Test
|
||||||
|
echo "works" | mo
|
||||||
|
|
||||||
|
|
||||||
|
### As A Library; For A Tool
|
||||||
|
|
||||||
|
Bash scripts can source `mo` to include the functionality in their own routines. This usage typically would have `mo` saved to a `lib/` folder in an application and your other scripts would use `. lib/mo` to bring it into your project.
|
||||||
|
|
||||||
|
# Download
|
||||||
|
curl -sSL https://raw.githubusercontent.com/tests-always-included/mo/master/mo -o mo
|
||||||
|
|
||||||
|
# Move into your project folder
|
||||||
|
mv mo ~/projects/amazing-things/lib/
|
||||||
|
|
||||||
|
To allow it to work this way, you either should source the file (`. "lib/mo"`) or make it executable (`chmod +x lib/mo`) and run it from your scripts.
|
||||||
|
|
||||||
|
|
||||||
|
How to Use
|
||||||
|
----------
|
||||||
|
|
||||||
|
If you only plan using strings and numbers, nothing could be simpler. In your shell script you can choose to export the variables. The below script is [`demo/using-strings`](demo/using-strings).
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
export TEST="This is a test"
|
||||||
|
echo "Your message: {{TEST}}" | ../mo
|
||||||
|
|
||||||
|
The result? "Your message: This is a test".
|
||||||
|
|
||||||
|
Using arrays adds a slight level of complexity. *You must source `mo`.* Look at [`demo/using-arrays`](demo/using-arrays).
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
export ARRAY=( one two "three three three" four five )
|
||||||
|
. ../mo # This loads the "mo" function
|
||||||
|
cat << EOF | mo
|
||||||
|
Here are the items in the array:
|
||||||
|
{{#ARRAY}}
|
||||||
|
* {{.}}
|
||||||
|
{{/ARRAY}}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
The result? You get a list of the five elements in the array. It is vital that you source `mo` and run the function when you want arrays to work because you can not execute a command and have arrays passed to that command's environment. Instead, we first source the file to load the function and then run the function directly.
|
||||||
|
|
||||||
|
There are more scripts available in the [demos directory](demo/) that could help illustrate how you would use this program.
|
||||||
|
|
||||||
|
There are additional features that the program supports. Try using `mo --help` to see what is available.
|
||||||
|
|
||||||
|
Please note that this command is written in Bash and pulls data from either the environment or (when using `--source`) from a text file that will be sourced and loaded into the environment, which means you will need to have Bash-style variables defined. Please see the examples in `demo/` for different ways you can use `mo`.
|
||||||
|
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
|
||||||
|
In addition to many of the features built-in to Mustache, `mo` includes a number of unique features that make it a bit more powerful.
|
||||||
|
|
||||||
|
### Loop @key
|
||||||
|
|
||||||
|
`mo` implements Handlebar's `@key` references for outputting the key inside of a loop:
|
||||||
|
|
||||||
|
Env:
|
||||||
|
```bash
|
||||||
|
myarr=( foo bar )
|
||||||
|
|
||||||
|
# Bash v4+
|
||||||
|
declare -A myassoc
|
||||||
|
myassoc[hello]="mo"
|
||||||
|
myassoc[world]="is great"
|
||||||
|
```
|
||||||
|
|
||||||
|
Template:
|
||||||
|
```handlebars
|
||||||
|
{{#myarr}}
|
||||||
|
- {{@key}} {{.}}
|
||||||
|
{{/myarr}}
|
||||||
|
|
||||||
|
{{#myassoc}}
|
||||||
|
* {{@key}} {{.}}
|
||||||
|
{{/myassoc}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
```markdown
|
||||||
|
- 0 foo
|
||||||
|
- 1 bar
|
||||||
|
|
||||||
|
* hello mo
|
||||||
|
* world is great
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Helpers / Function Arguments
|
||||||
|
|
||||||
|
Function Arguments are not a part of the official Mustache implementation, and are more often associated with Handlebar's Helper functionality.
|
||||||
|
|
||||||
|
`mo` allows for passing strings to functions.
|
||||||
|
|
||||||
|
```handlebars
|
||||||
|
{{myfunc foo bar}}
|
||||||
|
```
|
||||||
|
|
||||||
|
For security reasons, these arguments are not immediately available to function calls without a flag.
|
||||||
|
|
||||||
|
#### with `--allow-function-arguments`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
myfunc() {
|
||||||
|
# Outputs "foo, bar"
|
||||||
|
echo "$1, $2";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Using `$MO_FUNCTION_ARGS`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
myfunc() {
|
||||||
|
# Outputs "foo, bar"
|
||||||
|
echo "${MO_FUNCTION_ARGS[0]}, ${MO_FUNCTION_ARGS[1]}";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Triple Mustache, Parenthesis, and Quotes
|
||||||
|
|
||||||
|
Normally, triple mustache syntax, such as `{{{var}}}` will avoid HTML escaping of the variable. Because HTML escaping is not supported in `mo`, this is now used differently. Anything within braces will be looked up and the values will be concatenated together and the result will be treated as a value. Anything in parenthesis will be looked up, concatenated, and treated as a name. Also, anything in single quotes is passed as a value; double quoted things first are unescaped and then passed as a value.
|
||||||
|
|
||||||
|
```
|
||||||
|
# Example input
|
||||||
|
var=abc
|
||||||
|
user=admin
|
||||||
|
admin=Administrator
|
||||||
|
u=user
|
||||||
|
abc=([0]=zero [1]=one [2]=two)
|
||||||
|
```
|
||||||
|
|
||||||
|
| Mustache syntax | Resulting output | Notes |
|
||||||
|
|-----------------|------------------|-------|
|
||||||
|
| `{{var}}` | `abc` | Normal behavior |
|
||||||
|
| `{{var us}}` | `abcus` | Concatenation |
|
||||||
|
| `{{'var'}}` | `var` | Passing as a value |
|
||||||
|
| `{{"a\tb"}}` | `a b` | There was an escaped tab in the value |
|
||||||
|
| `{{u}}` | `user` | Normal behavior |
|
||||||
|
| `{{{u}}}` | `user` | Look up "$u", treat as the value `{{'user'}}` |
|
||||||
|
| `{{(u)}}` | `admin` | Look up "$u", treat as the name `{{user}}` |
|
||||||
|
| `{{var user}}` | `abcuser` | Concatenation |
|
||||||
|
| `{{(var '.1')}}` | `one` | Look up "$var", treat as "abc", then concatenate ".1" and look up `{{abc.1}}` |
|
||||||
|
|
||||||
|
In double-quoted strings, the following escape sequences are defined.
|
||||||
|
|
||||||
|
* `\"` - Quote
|
||||||
|
* `\b` - Bell
|
||||||
|
* `\e` - Escape (note that Bash typically uses $'\E' for the same thing)
|
||||||
|
* `\f` - Form feed
|
||||||
|
* `\n` - Newline
|
||||||
|
* `\r` - Carriage return
|
||||||
|
* `\t` - Tab
|
||||||
|
* `\v` - Vertical tab
|
||||||
|
* Anything else will skip the `\` and place the next character. However, this implementation is allowed to change in the future if a different escape character mapping becomes commonplace.
|
||||||
|
|
||||||
|
|
||||||
|
Environment Variables and Functions
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
There are several functions and variables used to process templates. `mo` reserves variables that start with `MO_` for variables exposing data or configuration, functions starting with `mo::`, and local variables starting with `mo[A-Z]`. You are welcome to use internal functions, though only ones that are marked as "Public" should not change their interface. Scripts may also read any of the variables.
|
||||||
|
|
||||||
|
Functions are all executed in a subshell, with another subshell for lambdas. Thus, your lambda can't affect the parsing of a template. There's more information about lambdas when talking about tests that fail.
|
||||||
|
|
||||||
|
* `MO_ALLOW_FUNCTION_ARGUMENTS` - When set to a non-empty value, this allows functions referenced in templates to receive additional options and arguments.
|
||||||
|
* `MO_CLOSE_DELIMITER` - The string used when closing a tag. Defaults to "}}". Used internally.
|
||||||
|
* `MO_CLOSE_DELIMITER_DEFAULT` - The default value of `MO_CLOSE_DELIMITER`. Used when resetting the close delimiter, such as when parsing a partial.
|
||||||
|
* `MO_CURRENT` - Variable name to use for ".".
|
||||||
|
* `MO_DEBUG` - When set to a non-empty value, additional debug information is written to stderr.
|
||||||
|
* `MO_FUNCTION_ARGS` - Arguments passed to the function.
|
||||||
|
* `MO_FAIL_ON_FILE` - If a filename from the command-line is missing or a partial does not exist, abort with an error.
|
||||||
|
* `MO_FAIL_ON_FUNCTION` - If a function returns a non-zero status code, abort with an error.
|
||||||
|
* `MO_FAIL_ON_UNSET` - When set to a non-empty value, expansion of an unset env variable will be aborted with an error.
|
||||||
|
* `MO_FALSE_IS_EMPTY` - When set to a non-empty value, the string "false" will be treated as an empty value for the purposes of conditionals.
|
||||||
|
* `MO_OPEN_DELIMITER` - The string used when opening a tag. Defaults to "{{". Used internally.
|
||||||
|
* `MO_OPEN_DELIMITER_DEFAULT` - The default value of MO_OPEN_DELIMITER. Used when resetting the open delimiter, such as when parsing a partial.
|
||||||
|
* `MO_ORIGINAL_COMMAND` - Used to find the `mo` program in order to generate a help message.
|
||||||
|
* `MO_PARSED` - Content that has made it through the template engine.
|
||||||
|
* `MO_STANDALONE_CONTENT` - The unparsed content that preceeded the current tag. When a standalone tag is encountered, this is checked to see if it only contains whitespace. If this and the whitespace condition after a tag is met, then this will be reset to $'\n'.
|
||||||
|
* `MO_UNPARSED` - Template content yet to make it through the parser.
|
||||||
|
|
||||||
|
|
||||||
|
Concessions
|
||||||
|
-----------
|
||||||
|
|
||||||
|
I admit that implementing everything in bash just doesn't make a lot of sense. For example, the following things just don't work because they don't really mesh with the "bash way".
|
||||||
|
|
||||||
|
Pull requests to solve the following issues would be helpful.
|
||||||
|
|
||||||
|
|
||||||
|
### Mustache Syntax
|
||||||
|
|
||||||
|
* Dotted names are supported but only for associative arrays (Bash 4). See [`demo/associative-arrays`](demo/associative-arrays) for an example.
|
||||||
|
* There's no "top level" object, so `echo '{{.}}' | ./mo` does not do anything useful. In other languages you can say the data for the template is a string and in `mo` the data is always the environment. Luckily this type of usage is rare and `{{.}}` works great when iterating over an array.
|
||||||
|
* [Parents](https://mustache.github.io/mustache.5.html#Parents), where a template can override chunks of a partial, are not supported.
|
||||||
|
* HTML encoding is not built into `mo`. `{{{var}}}`, `{{&var}}` and `{{var}}` all do the same thing. `echo '{{TEST}}' | TEST='<b>' mo` will give you "`<b>`" instead of "`>b<`".
|
||||||
|
|
||||||
|
|
||||||
|
### General Scripting Issues
|
||||||
|
|
||||||
|
* Using binary files as templates is simply not allowed.
|
||||||
|
* Bash does not support anything more complex than strings/numbers inside of associative arrays. I'm not able to add objects nor nested arrays to bash - it's just a shell after all!
|
||||||
|
* You must make sure the data is in the environment when `mo` runs. The easiest way to do that is to source `mo` in your shell script after setting up lots of other environment variables / functions.
|
||||||
|
|
||||||
|
|
||||||
|
Developing
|
||||||
|
----------
|
||||||
|
|
||||||
|
Check out the code and hack away. Please add tests to show off bugs before fixing them. New functionality should also be covered by a test.
|
||||||
|
|
||||||
|
First, make sure you install Node.js. After that, run `npm run install-tests` to get the dependencies and the repository of YAML tests. Run `npm run test` to run the JavaScript tests. There's over 100 of them, which is great. Not all of them will pass, but that's discussed later.
|
||||||
|
|
||||||
|
When submitting patches, make sure to run them past [ShellCheck] and ensure no problems are found. Also please use Bash 3 syntax if you are manipulating arrays.
|
||||||
|
|
||||||
|
|
||||||
|
### Porting and Backporting
|
||||||
|
|
||||||
|
In case of problems, setting MO_DEBUG to a non-empty value will give you LOTS of output.
|
||||||
|
|
||||||
|
MO_DEBUG=1 ./mo my-template
|
||||||
|
|
||||||
|
|
||||||
|
### Failed Specs
|
||||||
|
|
||||||
|
It is acceptable for some of the official spec tests to fail. The spec runner has specific exclusions and overrides to test similar functionality that avoid the following issues.
|
||||||
|
|
||||||
|
* Using `{{.}}` outside of a loop - In order to access any variable, you must use its name. In a loop, `{{.}}` will refer to the current value, but outside the loop you are unable to use this dot notation because there is no current value.
|
||||||
|
* Deeply nested data - Bash doesn't support complex data structure. Basically, just strings and arrays of strings.
|
||||||
|
* Interpolation; Multiple Calls: This fails because lambdas execute in a subshell so their output can be captured. If you want state to be preserved, you will need to write it outside of the current environment and load it again later.
|
||||||
|
* HTML Escaping - Since bash is not often executed in a web server context, it makes no sense to have the output escaped as HTML. Performing shell escaping of variables may be an option in the future if there's a demand.
|
||||||
|
* Lambdas - Function results are *not* automatically interpreted again. If you want to parse the results as Mustache content, use `mo::parse`. When they use `mo::parse`, it will use the current delimiters.
|
||||||
|
|
||||||
|
For lambdas, these examples may help.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Retrieve content into a variable.
|
||||||
|
content=$(cat)
|
||||||
|
|
||||||
|
# Retrieve all content and do not trim newlines at the end.
|
||||||
|
content=$(cat; echo -n '.')
|
||||||
|
content=${content%.}
|
||||||
|
|
||||||
|
# Parse content using the current delimiters
|
||||||
|
mo::parse results "This is my content. Hello, {{username}}"
|
||||||
|
echo -n "$results"
|
||||||
|
|
||||||
|
# Parse content using the default delimiters
|
||||||
|
MO_OPEN_DELIMITER=$MO_OPEN_DELIMITER_DEFAULT
|
||||||
|
MO_CLOSE_DELIMITER=$MO_CLOSE_DELIMITER_DEFAULT
|
||||||
|
mo::parse results "This is my content. Hello, {{username}}"
|
||||||
|
echo -n "$results"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Future Enhancements
|
||||||
|
|
||||||
|
There's a few places in the code marked with `TODO` to signify areas that could use improvement. Care to help? Keep in mind that this uses bash exclusively, so it might not look the prettiest.
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
This program is licensed under an MIT license with an additional non-advertising clause. See [LICENSE.md](LICENSE.md) for the full text.
|
||||||
|
|
||||||
|
|
||||||
|
[Mustache]: https://mustache.github.io/
|
||||||
|
[ShellCheck]: https://github.com/koalaman/shellcheck
|
19
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/associative-arrays
generated
vendored
Executable file
19
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/associative-arrays
generated
vendored
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
|
||||||
|
declare -A DATA
|
||||||
|
export DATA=([one]=111 [two]=222)
|
||||||
|
. ../mo
|
||||||
|
|
||||||
|
cat <<EOF | mo
|
||||||
|
Accessing data directly:
|
||||||
|
DATA: {{DATA}}
|
||||||
|
One: {{DATA.one}}
|
||||||
|
Two: {{DATA.two}}
|
||||||
|
|
||||||
|
Things in DATA:
|
||||||
|
{{#DATA}}
|
||||||
|
Item: {{.}}
|
||||||
|
{{/DATA}}
|
||||||
|
EOF
|
28
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/embedded-template
generated
vendored
Executable file
28
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/embedded-template
generated
vendored
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# This embeds a template in the script without using strange `cat` syntax.
|
||||||
|
# shellcheck disable=SC1083 disable=SC1010 disable=SC1054 disable=SC1073 disable=SC1072 disable=SC1056 disable=SC1009
|
||||||
|
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
|
||||||
|
export NAME="Tyler"
|
||||||
|
export VEHICLE="Ford Explorer"
|
||||||
|
export OVERDUE_LENGTH="2 months"
|
||||||
|
export OPTIONS=(
|
||||||
|
"Call a service representative at 1-800-000-0000 to discuss payment options"
|
||||||
|
"Return the vehicle immediately and pay a fine of 1 million dollars"
|
||||||
|
)
|
||||||
|
. ../mo
|
||||||
|
sed '0,/^# END/ d' "$(basename "$0")" | mo
|
||||||
|
exit
|
||||||
|
|
||||||
|
# END
|
||||||
|
Attention {{NAME}},
|
||||||
|
|
||||||
|
You need to pay for the {{VEHICLE}} you are leasing from us.
|
||||||
|
It has been {{OVERDUE_LENGTH}} since your last payment.
|
||||||
|
At this point you must do one of the following:
|
||||||
|
|
||||||
|
{{#OPTIONS}}
|
||||||
|
* {{.}}
|
||||||
|
{{/OPTIONS}}
|
3
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/fun-trip.mo
generated
vendored
Normal file
3
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/fun-trip.mo
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Hello, {{NAME}}
|
||||||
|
|
||||||
|
I hope your {{TIME_PERIOD}} was fun.
|
31
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args
generated
vendored
Executable file
31
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args
generated
vendored
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# This sources a simple script with the env. variables needed for the template.
|
||||||
|
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
source ../mo
|
||||||
|
|
||||||
|
export NAME="Alex"
|
||||||
|
export ARRAY=( AAA BBB CCC )
|
||||||
|
|
||||||
|
# Include an external template
|
||||||
|
INCLUDE() {
|
||||||
|
# shellcheck disable=SC2031
|
||||||
|
cat "${MO_FUNCTION_ARGS[0]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print section title
|
||||||
|
TITLE() {
|
||||||
|
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
||||||
|
# shellcheck disable=SC2031
|
||||||
|
echo "${MO_FUNCTION_ARGS[0]}"
|
||||||
|
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
|
||||||
|
}
|
||||||
|
|
||||||
|
cat <<EOF | mo -u
|
||||||
|
{{TITLE 'Part 1'}}
|
||||||
|
{{INCLUDE 'function-args-part1'}}
|
||||||
|
|
||||||
|
{{TITLE 'Part 2'}}
|
||||||
|
{{INCLUDE 'function-args-part2'}}
|
||||||
|
EOF
|
1
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args-part1
generated
vendored
Normal file
1
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args-part1
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hello, my name is {{NAME}}.
|
3
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args-part2
generated
vendored
Normal file
3
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-args-part2
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{#ARRAY}}
|
||||||
|
* {{.}}
|
||||||
|
{{/ARRAY}}
|
42
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-for-advanced-looping
generated
vendored
Executable file
42
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-for-advanced-looping
generated
vendored
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
|
||||||
|
EVERY_REPO() {
|
||||||
|
# The block contents come in through standard input. Capture it here.
|
||||||
|
content=$(cat)
|
||||||
|
|
||||||
|
echo "# Starting EVERY_REPO"
|
||||||
|
|
||||||
|
# Get list of repos
|
||||||
|
for REPO in "${REPOS[@]}"; do
|
||||||
|
echo "## Looping one time for repo: $REPO"
|
||||||
|
|
||||||
|
# String replace REPO_ with the name
|
||||||
|
# This changes everything in the content block of the template.
|
||||||
|
# It rewrites {{__REPO__.name}} into {{resque.name}}, for instance.
|
||||||
|
# You can prefix your environment variables and do other things as well.
|
||||||
|
|
||||||
|
echo "$content" | sed "s/__REPO__/${REPO}/"
|
||||||
|
|
||||||
|
echo "## Looped one time for repo: $REPO"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "# Finished EVERY_REPO"
|
||||||
|
}
|
||||||
|
|
||||||
|
REPOS=(resque hub rip)
|
||||||
|
|
||||||
|
declare -A resque hub rip
|
||||||
|
resque=([name]=Resque [url]=http://example.com/resque)
|
||||||
|
hub=([name]=Hub [url]=http://example.com/hub)
|
||||||
|
rip=([name]=Rip [url]=http://example.com/rip)
|
||||||
|
. ../mo
|
||||||
|
cat <<EOF | mo
|
||||||
|
{{#EVERY_REPO}}
|
||||||
|
The repo is __REPO__
|
||||||
|
Name: {{__REPO__.name}}
|
||||||
|
URL: {{__REPO__.url}}
|
||||||
|
{{/EVERY_REPO}}
|
||||||
|
|
||||||
|
EOF
|
39
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-for-building-json
generated
vendored
Executable file
39
vendor/git.knownelement.com/ExternalVendorCode/mo/demo/function-for-building-json
generated
vendored
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
|
||||||
|
# Detect if this is the first item and write a comma if it is.
|
||||||
|
# Normally, I would track this using a variable, like so:
|
||||||
|
#
|
||||||
|
# COMMA_IF_NOT_FIRST_FLAG=false
|
||||||
|
# COMMA_IF_NOT_FIRST() {
|
||||||
|
# $COMMA_IF_NOT_FIRST || echo ","
|
||||||
|
# COMMA_IF_NOT_FIRST_FLAG=true
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# Since this function executes in a subshell, that approach will not work.
|
||||||
|
# Instead, we peek inside mo and see what is being processed. If the variable
|
||||||
|
# name in moParse() changes, this will need to get updated as well. An
|
||||||
|
# alternate variable that is usable is context, but that is in moLoop() and is
|
||||||
|
# two levels levels deep instead of just one.
|
||||||
|
COMMA_IF_NOT_FIRST() {
|
||||||
|
[[ "${moCurrent#*.}" != "0" ]] && echo ","
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create an array that will be embedded into the JSON. If you are manipulating
|
||||||
|
# JSON, might I suggest you look at using jq? It's really good at processing
|
||||||
|
# JSON.
|
||||||
|
items=(
|
||||||
|
'{"position":"one","url":"1"}'
|
||||||
|
'{"position":"two","url":"2"}'
|
||||||
|
'{"position":"three","url":"3"}'
|
||||||
|
)
|
||||||
|
. ../mo
|
||||||
|
cat <<EOF | mo
|
||||||
|
{
|
||||||
|
{{#items}}
|
||||||
|
{{COMMA_IF_NOT_FIRST}}
|
||||||
|
{{.}}
|
||||||
|
{{/items}}
|
||||||
|
}
|
||||||
|
EOF
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user