SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
dry-wit
Bash framework
Jose San Leandro @rydnr
OSOCO
Contents
1 Introduction
2 dry-wit approach
3 dry-wit hooks
4 dry-wit API
5 Try it
Bash
In theory
• Powerful language.
• Conventions improve
reusability and
maintainability.
• Great fit for Unix and OSs
with strong command-line
focus.
dry-wit Introduction 3 / 16
Bash
In theory
• Powerful language.
• Conventions improve
reusability and
maintainability.
• Great fit for Unix and OSs
with strong command-line
focus.
In practice
• Easy to start with.
• Difficult to master.
• Write once, use twice,
dispose.
• Expensive maintenance.
• Hardly reusable.
dry-wit Introduction 3 / 16
dry-wit: Features
Features
1 Provides a consistent way to structure scripts.
2 Manages required dependencies.
3 Declarative approach for dealing with errors (Output message
+ error code).
4 Handles parameters, flags, and environment variables.
5 API for creating temporary files, logging, etc.
6 Composability: scripts can be injected into others.
dry-wit dry-wit approach 4 / 16
Usage / Help
usage()
function usage() {
cat <<EOF
Does this and that...
Where:
* myflag: changes the behavior somehow.
* param1: the first input.
Common flags:
* -h | --help: Display this message.
* -v: Increase the verbosity.
* -vv: Increase the verbosity further.
* -q | --quiet: Be silent.
EOF
}
dry-wit dry-wit hooks 5 / 16
Input: checking
checkInput()
function checkInput() {
local _flags=$(extractFlags $@);
logDebug -n "Checking input";
for _flag in ${_flags}; do
case ${_flag} in
-h | --help | -v | -vv | -f | --my-flag)
;;
*) logDebugResult FAILURE "fail";
exitWithErrorCode INVALID_OPTION ${_flag};
;;
esac
done
}
dry-wit dry-wit hooks 6 / 16
Input: parsing
parseInput()
function parseInput() {
local _flags=$(extractFlags $@);
for _flag in ${_flags}; do
case ${_flag} in
-f | --my-flag)
shift;
export MY_FLAG="${1}";
shift;
;;
*) shift;
;;
esac
done
}
dry-wit dry-wit hooks 7 / 16
Script requirements
Dependencies
function checkRequirements() {
checkReq docker DOCKER_NOT_INSTALLED;
checkReq realpath REALPATH_NOT_INSTALLED;
checkReq envsubst ENVSUBST_NOT_INSTALLED;
}
DSL
1 executable-file: The required dependency.
2 message: The name of a constant describing the error to
display should the dependency is not present.
3 dry-wit checks each dependency and exits if the check fails.
dry-wit dry-wit hooks 8 / 16
Error messages
defineErrors()
function defineErrors() {
export INVALID_OPTION="Unrecognized option";
export DOCKER_NOT_INSTALLED="docker is not installed. See http://www.docker.org";
export REPOSITORY_IS_MANDATORY="The repository argument is mandatory";
ERROR_MESSAGES=(
INVALID_OPTION 
DOCKER_NOT_INSTALLED 
REPOSITORY_IS_MANDATORY 
);
export ERROR_MESSAGES;
}
dry-wit takes care of the exit codes
exitWithErrorCode REPOSITORY_IS_MANDATORY;
dry-wit dry-wit hooks 9 / 16
main()
main()
function main() {
// Focus on the logic itself.
// Forget about defensive programming
// regarding input variables
// or dependencies.
// Start by writing pseudo-code,
// and later define the identified
// functions.
}
dry-wit dry-wit hooks 10 / 16
Logging
logging
logInfo -n "Calculating next prime number ...";
...
if [ $? -eq 0 ]; then
logInfoResult SUCCESS "done";
else
logInfoResult FAILURE "Too optimistic";
fi
output
[2015/10/26 15:09:54 my-script:main] Calculating next prime number ... [done]
dry-wit dry-wit API 11 / 16
Temporary files
API functions
1 Functions to create temporary files or folders.
2 dry-wit takes cares of cleaning them up afterwards.
createTempFile()
createTempFile;
local tempFile=${RESULT};
createTempFolder()
createTempFolder;
local tempFolder=${RESULT};
dry-wit dry-wit API 12 / 16
Environment variables: Declaration (1/3)
DSL for declaring environment variables
1 Declared in [script].inc.sh.
2 Safe to add to version control systems.
3 Mandatory information: description and default value.
defineEnvVar()
defineEnvVar 
MYPASSWORD 
"The description of MYPASSWORD" 
"secret";
dry-wit dry-wit API 13 / 16
Environment variables: Overridding (2/3)
DSL for overridding default values
1 Declared in .[script].inc.sh.
2 Not always safe to add to version control systems.
overrideEnvVar()
overrideEnvVar MYPASSWORD ".toor!";
dry-wit dry-wit API 14 / 16
Environment variables: Overridding (3/3)
Environment value overridden from the command line
MYPASSWORD="abc123" ./script.sh ...
dry-wit dry-wit API 15 / 16
Free as in freedom
You’re welcome to try, fork, improve, even criticize!
https://github.com/rydnr/dry-wit
dry-wit Try it 16 / 16

Mais conteúdo relacionado

Mais procurados (11)

Exceptions handling in java
Exceptions handling in javaExceptions handling in java
Exceptions handling in java
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Multi catch statement
Multi catch statementMulti catch statement
Multi catch statement
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
 
Exception handling in Java
Exception handling in JavaException handling in Java
Exception handling in Java
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Exceptionhandling
ExceptionhandlingExceptionhandling
Exceptionhandling
 
Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Exception
ExceptionException
Exception
 
Extrabacon's sploit core
Extrabacon's sploit coreExtrabacon's sploit core
Extrabacon's sploit core
 

Semelhante a Dry-wit Overview

Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator
Alessio Ricco
 
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
Whymca
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CanSecWest
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
Android Open source coading guidel ine
Android Open source coading guidel ineAndroid Open source coading guidel ine
Android Open source coading guidel ine
Pragati Singh
 
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbersDefcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Alexandre Moneger
 

Semelhante a Dry-wit Overview (20)

PHP 7 Crash Course
PHP 7 Crash CoursePHP 7 Crash Course
PHP 7 Crash Course
 
Php 7 crash course
Php 7 crash coursePhp 7 crash course
Php 7 crash course
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015
 
Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator
 
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
BEST PRACTICES PER LA SCRITTURA DI APPLICAZIONI TITANIUM APPCELERATOR - Aless...
 
Exception handling
Exception handlingException handling
Exception handling
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
Defcon 27 - Writing custom backdoor payloads with C#
Defcon 27 - Writing custom backdoor payloads with C#Defcon 27 - Writing custom backdoor payloads with C#
Defcon 27 - Writing custom backdoor payloads with C#
 
Red Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift MessengerRed Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift Messenger
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_Workshop
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Shell Script Tutorial
Shell Script TutorialShell Script Tutorial
Shell Script Tutorial
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitation
 
Android Open source coading guidel ine
Android Open source coading guidel ineAndroid Open source coading guidel ine
Android Open source coading guidel ine
 
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbersDefcon 22 - Stitching numbers - generating rop payloads from in memory numbers
Defcon 22 - Stitching numbers - generating rop payloads from in memory numbers
 
Anatomy of PHP Shells
Anatomy of PHP ShellsAnatomy of PHP Shells
Anatomy of PHP Shells
 

Mais de OSOCO (8)

HackaTrips 2017 Team 10
HackaTrips 2017 Team 10HackaTrips 2017 Team 10
HackaTrips 2017 Team 10
 
Take the Smalltalk Red Pill
Take the Smalltalk Red PillTake the Smalltalk Red Pill
Take the Smalltalk Red Pill
 
Spring Annotations: Proxy
Spring Annotations: ProxySpring Annotations: Proxy
Spring Annotations: Proxy
 
Proactive monitoring with Monit
Proactive monitoring with MonitProactive monitoring with Monit
Proactive monitoring with Monit
 
XSS Countermeasures in Grails
XSS Countermeasures in GrailsXSS Countermeasures in Grails
XSS Countermeasures in Grails
 
AWS CloudFormation en 5 Minutos
AWS CloudFormation en 5 MinutosAWS CloudFormation en 5 Minutos
AWS CloudFormation en 5 Minutos
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic Proxies
 
SSH Tunneling Recipes
SSH Tunneling RecipesSSH Tunneling Recipes
SSH Tunneling Recipes
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

Dry-wit Overview

  • 1. dry-wit Bash framework Jose San Leandro @rydnr OSOCO
  • 2. Contents 1 Introduction 2 dry-wit approach 3 dry-wit hooks 4 dry-wit API 5 Try it
  • 3. Bash In theory • Powerful language. • Conventions improve reusability and maintainability. • Great fit for Unix and OSs with strong command-line focus. dry-wit Introduction 3 / 16
  • 4. Bash In theory • Powerful language. • Conventions improve reusability and maintainability. • Great fit for Unix and OSs with strong command-line focus. In practice • Easy to start with. • Difficult to master. • Write once, use twice, dispose. • Expensive maintenance. • Hardly reusable. dry-wit Introduction 3 / 16
  • 5. dry-wit: Features Features 1 Provides a consistent way to structure scripts. 2 Manages required dependencies. 3 Declarative approach for dealing with errors (Output message + error code). 4 Handles parameters, flags, and environment variables. 5 API for creating temporary files, logging, etc. 6 Composability: scripts can be injected into others. dry-wit dry-wit approach 4 / 16
  • 6. Usage / Help usage() function usage() { cat <<EOF Does this and that... Where: * myflag: changes the behavior somehow. * param1: the first input. Common flags: * -h | --help: Display this message. * -v: Increase the verbosity. * -vv: Increase the verbosity further. * -q | --quiet: Be silent. EOF } dry-wit dry-wit hooks 5 / 16
  • 7. Input: checking checkInput() function checkInput() { local _flags=$(extractFlags $@); logDebug -n "Checking input"; for _flag in ${_flags}; do case ${_flag} in -h | --help | -v | -vv | -f | --my-flag) ;; *) logDebugResult FAILURE "fail"; exitWithErrorCode INVALID_OPTION ${_flag}; ;; esac done } dry-wit dry-wit hooks 6 / 16
  • 8. Input: parsing parseInput() function parseInput() { local _flags=$(extractFlags $@); for _flag in ${_flags}; do case ${_flag} in -f | --my-flag) shift; export MY_FLAG="${1}"; shift; ;; *) shift; ;; esac done } dry-wit dry-wit hooks 7 / 16
  • 9. Script requirements Dependencies function checkRequirements() { checkReq docker DOCKER_NOT_INSTALLED; checkReq realpath REALPATH_NOT_INSTALLED; checkReq envsubst ENVSUBST_NOT_INSTALLED; } DSL 1 executable-file: The required dependency. 2 message: The name of a constant describing the error to display should the dependency is not present. 3 dry-wit checks each dependency and exits if the check fails. dry-wit dry-wit hooks 8 / 16
  • 10. Error messages defineErrors() function defineErrors() { export INVALID_OPTION="Unrecognized option"; export DOCKER_NOT_INSTALLED="docker is not installed. See http://www.docker.org"; export REPOSITORY_IS_MANDATORY="The repository argument is mandatory"; ERROR_MESSAGES=( INVALID_OPTION DOCKER_NOT_INSTALLED REPOSITORY_IS_MANDATORY ); export ERROR_MESSAGES; } dry-wit takes care of the exit codes exitWithErrorCode REPOSITORY_IS_MANDATORY; dry-wit dry-wit hooks 9 / 16
  • 11. main() main() function main() { // Focus on the logic itself. // Forget about defensive programming // regarding input variables // or dependencies. // Start by writing pseudo-code, // and later define the identified // functions. } dry-wit dry-wit hooks 10 / 16
  • 12. Logging logging logInfo -n "Calculating next prime number ..."; ... if [ $? -eq 0 ]; then logInfoResult SUCCESS "done"; else logInfoResult FAILURE "Too optimistic"; fi output [2015/10/26 15:09:54 my-script:main] Calculating next prime number ... [done] dry-wit dry-wit API 11 / 16
  • 13. Temporary files API functions 1 Functions to create temporary files or folders. 2 dry-wit takes cares of cleaning them up afterwards. createTempFile() createTempFile; local tempFile=${RESULT}; createTempFolder() createTempFolder; local tempFolder=${RESULT}; dry-wit dry-wit API 12 / 16
  • 14. Environment variables: Declaration (1/3) DSL for declaring environment variables 1 Declared in [script].inc.sh. 2 Safe to add to version control systems. 3 Mandatory information: description and default value. defineEnvVar() defineEnvVar MYPASSWORD "The description of MYPASSWORD" "secret"; dry-wit dry-wit API 13 / 16
  • 15. Environment variables: Overridding (2/3) DSL for overridding default values 1 Declared in .[script].inc.sh. 2 Not always safe to add to version control systems. overrideEnvVar() overrideEnvVar MYPASSWORD ".toor!"; dry-wit dry-wit API 14 / 16
  • 16. Environment variables: Overridding (3/3) Environment value overridden from the command line MYPASSWORD="abc123" ./script.sh ... dry-wit dry-wit API 15 / 16
  • 17. Free as in freedom You’re welcome to try, fork, improve, even criticize! https://github.com/rydnr/dry-wit dry-wit Try it 16 / 16