{"id":24991246,"url":"https://github.com/stefaanc/steps","last_synced_at":"2026-04-15T16:08:28.158Z","repository":{"id":77671078,"uuid":"192939885","full_name":"stefaanc/steps","owner":"stefaanc","description":"redirect the output of commands in your shell scripts to a log-file, while writing your own information to the terminal - handle errors and exits in a concise and consistent manner - all with similar behavior in different shells","archived":false,"fork":false,"pushed_at":"2019-08-19T15:30:19.000Z","size":3050,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T01:34:46.100Z","etag":null,"topics":["bash","error-handling","logging","powershell","steps"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefaanc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-20T14:58:42.000Z","updated_at":"2021-02-18T19:58:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f0d206e-da93-45aa-9173-4e61caddb507","html_url":"https://github.com/stefaanc/steps","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stefaanc/steps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fsteps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fsteps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fsteps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fsteps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefaanc","download_url":"https://codeload.github.com/stefaanc/steps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefaanc%2Fsteps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31848800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","error-handling","logging","powershell","steps"],"created_at":"2025-02-04T13:47:42.323Z","updated_at":"2026-04-15T16:08:28.131Z","avatar_url":"https://github.com/stefaanc.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STEPS\r\n\r\n**a small library** \r\n\r\n- **to redirect the output of commands in your shell scripts to a log-file, while writing your own information to the terminal.**\r\n- **to handle errors and exits in a concise and consistent manner**\r\n- **with similar behaviour in different shells.**\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n\u003e Have you ever found your terminal \"polluted\" by all the stuff that is written by the commands in your scripts?\r\n\u003e\r\n\u003e - You can easily redirect the standard output to a log-file.\r\n\u003e - You can easily redirect the error output to a log-file.\r\n\u003e\r\n\u003e\r\n\u003e Have you ever redirected the standard output of your script to a log-file, but wanted a way to write some summary info to your terminal?  \r\n\u003e Have you ever redirected the error output of your script to a log-file, but still wanted to see an indication of these errors on your terminal?  \r\n\u003e Have you ever had trouble distinguishing between output from the main script and the output from a nested script?  \r\n\u003e Have you ever wished for code that handles output in different shells in a more similar way?\r\n\u003e\r\n\u003e- **STEPS will help you with this.**\r\n\u003e\r\n\u003e\r\n\u003e and...\r\n\u003e \r\n\u003e Have you ever had trouble with errors in a script, causing trouble further down the line in the same or another script.\r\n\u003e\r\n\u003e - You can easily test the exit code of the last command and act on it (ps: `$LASTEXITCODE`, bash: `$?`)\r\n\u003e - You can easily test the execution status of the last command and act on it (ps: `$?`)\r\n\u003e - You can easily set a preferred error action to be taken (ps: `$ErrorActionPreference`)\r\n\u003e - You can also use more advanced exception techniques for errors (ps: `try`, `catch`, `finally`)\r\n\u003e - You can also use more advanced trapping techniques for errors (ps: `trap`, bash: `trap ERR`)\r\n\u003e - You can also use more advanced trapping techniques for exits (bash: `trap EXIT`)\r\n\u003e\r\n\u003e\r\n\u003e Have you ever found you program full of boiler-plate code to handle exit-codes, execution-statuses and exceptions?  \r\n\u003e Have you ever had trouble with your error-handling code when scripts are called by other scripts?  \r\n\u003e Have you ever found it difficult to implement and maintain consistent error behaviour and output for all these different techniques?  \r\n\u003e Are you sure you are exiting all your scripts with all the right exit conditions, everywhere in your code?  \r\n\u003e Have you ever wished for code that handles errors in different shells in a more similar way?\r\n\u003e\r\n\u003e - **STEPS will help you with this.**\r\n\u003e\r\n\u003e\r\n\u003e and finally...\r\n\u003e \r\n\u003e Are you having trouble finding out about all these different techniques for different shells, trawling through 10s or perhaps even 100s of web-pages?  \r\n\u003e Have you given up \u003cdel\u003ewasting\u003c/del\u003e spending all this time finding and understanding all of these techniques that are often minimally documented?\r\n\u003e\r\n\u003e - **STEPS will help you with this.**\r\n\u003e\r\n\u003e\r\n\r\n\u003cbr/\u003e\r\n\r\n\u003e and a very last one...\r\n\u003e\r\n\u003e Are you curious about some of the solutions we found to solve the above problems?  \r\n\u003e Do you want to learn how to do something similar yourself?\r\n\u003e\r\n\u003e - **STEPS will help you with this.**\r\n\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n## Getting Started With STEPS In Powershell\r\n\r\nCopy the STEPS library into your scripts directory.  You can find it on github in the STEPS project: `/scripts/.steps.ps1`\r\n\r\n### The Basics\r\n\r\n#### [A successful script](./docs/powershell/a-successful-script.md)\r\n\r\n![intro-1.no-logging.png](./docs/powershell/screenshots/intro-1.no-logging.png)\r\n\r\n#### [Summarizing to terminal and logging to file](./docs/powershell/summarizing-to-terminal-and-logging-to-file.md)\r\n\r\n![intro-1.successful.png](./docs/powershell/screenshots/intro-1.successful.png)\r\n\r\n#### [Generating an error](./docs/powershell/generating-an-error.md)\r\n\r\n![intro-1.failed.png](./docs/powershell/screenshots/intro-1.failed.png)\r\n\r\n#### [Exiting](./docs/powershell/exiting.md)\r\n\r\n![intro-1.exiting.do_exit.png](./docs/powershell/screenshots/intro-1.exiting.do_exit.png)\r\n\r\n#### [Catching exits](./docs/powershell/catching-exits.md)\r\n\r\n![intro-1.catch.png](./docs/powershell/screenshots/intro-1.catch.png)\r\n\r\n#### [Providing more information](./docs/powershell/providing-more-information.md)\r\n\r\n![intro-1.information.png](./docs/powershell/screenshots/intro-1.information.png)\r\n\r\n#### [Nesting scripts](./docs/powershell/nesting-scripts.md)\r\n\r\n![intro-1.nested.png](./docs/powershell/screenshots/intro-1.nested.png)\r\n\r\n#### [Cleaning Up](./docs/powershell/cleaning-up.md)\r\n\r\n![intro-1.cleanup.png](./docs/powershell/screenshots/intro-1.cleanup.png)\r\n\r\n### Advanced Topics\r\n\r\n[**Variables and functions**](./docs/powershell/variables-and-functions.md)  \r\n[**Scripts with parameters**](./docs/powershell/scripts-with-parameters.md)  \r\n[**Native commands that write status-info to stderr**](./docs/powershell/native-commands-that-write-status-info-to-stderr.md)  \r\n[**Native commands that use exitcode for status-info**](./docs/powershell/native-commands-that-use-exitcode-for-status-info.md)  \r\n[**Appending to a log-file**](./docs/powershell/appending-to-a-log-file.md)  \r\n[**Changing colors**](./docs/powershell/changing-colors.md)\r\n\r\n### Techniques\r\n\r\n[**Providing Information During Long-Running Native Commands**](./docs/powershell/providing-information-during-long-running-native-commands.md)  \r\n[**Using Write-Error vs Throw**](./docs/powershell/using-write-error-vs-throw.md)  \r\n[**Playing with scopes - A successful call**](./docs/powershell/playing-with-scopes_a-successful-call.md)  \r\n[**Playing with scopes - A failed call**](./docs/powershell/playing-with-scopes_a-failed-call.md)\r\n\r\n### Troubleshooting\r\n\r\nWhen the script cannot dot-source the STEPS library or the script fails for some reason inside the library, you will typically get some error like\r\n\r\n![intro-1.trouble-1.png](./docs/powershell/screenshots/intro-1.trouble-1.png)\r\n\r\nThe issue is that the `do_trap` function has not yet been defined since the dot-sourcing failed.\r\nTo debug, comment out the `trap ( do_trap }` line in your script.  Be aware that the rest of your script will also run, so best to also put a `exit 1` line immediately after the `trap` line.  Re-running your script will now give more details about what is going wrong with the dot-sourcing.\r\n\r\n![intro-1.trouble-2.png](./docs/powershell/screenshots/intro-1.trouble-2.png)\r\n\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n## Getting Started With STEPS In Bash\r\n\r\nCopy the STEPS and GLOBALS library into your scripts directory.  You can find it on github in the STEPS project: `/scripts/.globals.bash` and `/scripts/.steps.bash`\r\n\r\n### The Basics\r\n\r\n#### [A successful script](./docs/bash/a-successful-script.md)\r\n\r\n![intro-3.no-logging.png](./docs/bash/screenshots/intro-3.no-logging.png)\r\n\r\n#### [Summarizing to terminal and logging to file](./docs/bash/summarizing-to-terminal-and-logging-to-file.md)\r\n\r\n![intro-3.successful.png](./docs/bash/screenshots/intro-3.successful.png)\r\n\r\n#### [Catching errors](./docs/bash/catching-errors.md)\r\n\r\n![intro-3.failed.png](./docs/bash/screenshots/intro-3.failed.png)\r\n\r\n#### [Exiting](./docs/bash/exiting.md)\r\n\r\n![intro-3.exiting.do_exit.png](./docs/bash/screenshots/intro-3.exiting.do_exit.png)\r\n\r\n#### [Providing more information](./docs/bash/providing-more-information.md)\r\n\r\n![intro-3.information.png](./docs/bash/screenshots/intro-3.information.png)\r\n\r\n#### [Nesting scripts](./docs/bash/nesting-scripts.md)\r\n\r\n![intro-3.nested.png](./docs/bash/screenshots/intro-3.nested.png)\r\n\r\n#### [Cleaning Up](./docs/bash/cleaning-up.md)\r\n\r\n![intro-3.cleanup.png](./docs/bash/screenshots/intro-3.cleanup.png)\r\n\r\n### Advanced Topics\r\n\r\n[**Variables and functions**](./docs/bash/variables-and-functions.md)  \r\n[**Appending to a log-file**](./docs/bash/appending-to-a-log-file.md)  \r\n[**Changing colors**](./docs/bash/changing-colors.md)\r\n\r\n### Techniques\r\n\r\n[**Providing Information During Long-Running Native Commands**](./docs/bash/providing-information-during-long-running-native-commands.md)  \r\n\r\n\r\n\r\n\u003cbr/\u003e\r\n\r\n## Calling A Script From Packer\r\n\r\n#### [Calling a powershell script from packer](./docs/powershell/calling-a-script-from-packer.md)\r\n\r\n![intro-1.packer.successful.png](./docs/powershell/screenshots/intro-1.packer.successful.png)\r\n\r\n![intro-1.packer.failed.png](./docs/powershell/screenshots/intro-1.packer.failed.png)\r\n\r\n#### [Calling a bash script from packer](./docs/bash/calling-a-script-from-packer.md)\r\n\r\n![intro-3.packer.successful.png](./docs/bash/screenshots/intro-3.packer.successful.png)\r\n\r\n![intro-3.packer.failed.png](./docs/bash/screenshots/intro-3.packer.failed.png)\r\n\r\n\r\n\r\n\u003cbr\u003e\r\n\r\n## For Further Investigation\r\n\r\n- in powershell: reset errors-array at start of a script (with an option?)\r\n- in powershell: research and cover other ways of running a command (f.i. powershell Invoke methods)\r\n- in powershell: add an option to leave root-script with exception instead of exitcode?\r\n- in powershell: research difference between white and red `$Error` output (see [**Native commands that write status-info to stderr**](./docs/powershell/native-commands-that-write-status-info-to-stderr.md))\r\n- in powershell: recover the output from native commands, written to `stderr` and stored in `$Error`, and write it to Success stream (see [**Native commands that write status-info to stderr**](./docs/powershell/native-commands-that-write-status-info-to-stderr.md)).\r\n- in bash: add a script/function trace to error output\r\n- use PSScriptAnalyser\r\n- automated testing (or automation assisted testing)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefaanc%2Fsteps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefaanc%2Fsteps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefaanc%2Fsteps/lists"}