{"id":15065597,"url":"https://github.com/alexskrypnyk/shellvar","last_synced_at":"2026-02-10T04:02:23.420Z","repository":{"id":144927225,"uuid":"616686959","full_name":"AlexSkrypnyk/shellvar","owner":"AlexSkrypnyk","description":"Utility to work with shell variables.","archived":false,"fork":false,"pushed_at":"2025-02-07T05:58:05.000Z","size":305,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T09:04:55.478Z","etag":null,"topics":["bash","extractor","shell","shell-script","variable"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexSkrypnyk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"patreon":"alexskrypnyk"}},"created_at":"2023-03-20T21:58:16.000Z","updated_at":"2025-01-10T00:17:01.000Z","dependencies_parsed_at":"2023-11-30T06:31:41.406Z","dependency_job_id":"ad135cf7-2230-48e5-a22d-b83e23fd4da4","html_url":"https://github.com/AlexSkrypnyk/shellvar","commit_stats":null,"previous_names":["alexskrypnyk/shellvar"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2Fshellvar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2Fshellvar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2Fshellvar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexSkrypnyk%2Fshellvar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexSkrypnyk","download_url":"https://codeload.github.com/AlexSkrypnyk/shellvar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248225710,"owners_count":21068078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","extractor","shell","shell-script","variable"],"created_at":"2024-09-25T00:42:47.345Z","updated_at":"2026-01-07T02:19:57.272Z","avatar_url":"https://github.com/AlexSkrypnyk.png","language":"PHP","funding_links":["https://patreon.com/alexskrypnyk"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"\" rel=\"noopener\"\u003e\n  \u003cimg width=200px height=200px src=\"https://placehold.jp/000000/ffffff/200x200.png?text=Shellvar\u0026css=%7B%22border-radius%22%3A%22%20100px%22%7D\" alt=\"Shellvar logo\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eUtility to work with shell variables\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![GitHub Issues](https://img.shields.io/github/issues/AlexSkrypnyk/shellvar.svg)](https://github.com/AlexSkrypnyk/shellvar/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/AlexSkrypnyk/shellvar.svg)](https://github.com/AlexSkrypnyk/shellvar/pulls)\n[![Test PHP](https://github.com/AlexSkrypnyk/shellvar/actions/workflows/test-php.yml/badge.svg)](https://github.com/AlexSkrypnyk/shellvar/actions/workflows/test-php.yml)\n[![codecov](https://codecov.io/gh/AlexSkrypnyk/shellvar/graph/badge.svg?token=7WEB1IXBYT)](https://codecov.io/gh/AlexSkrypnyk/shellvar)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/AlexSkrypnyk/shellvar)\n![LICENSE](https://img.shields.io/github/license/AlexSkrypnyk/shellvar)\n![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/drevops/shellvar?logo=docker)](https://hub.docker.com/r/drevops/shellvar)\n![amd64](https://img.shields.io/badge/arch-linux%2Famd64-brightgreen)\n\n\u003c/div\u003e\n\n---\n\n## Features\n\n- Lint variables:\n  - Report on shell variables that are not in `${VAR}` format.\n  - Fix shell variables that are not in `${VAR}` format.\n- Extract variables:\n  - Scan a file or a directory containing shell scripts and extract found\n    variables with comments and assigned values with [advanced interpolation\n    support](tests/phpunit/Fixtures/test-data-real.sh).\n  - Filter variables: exclude local, exclude by prefix, exclude from a list in\n    file.\n  - Format output as a _CSV_, _Markdown table_ or _Markdown blocks_ (defined in\n    the template).\n  - Extend filters and formatters with your own custom classes.\n\n## Installation\n\nDownload the latest version of the `shellvar` from\nthe [releases page](https://github.com/AlexSkrypnyk/shellvar/releases)\nand run on host machine:\n\n```bash\n./shellvar [command] [options] path/to/script.sh\n```\n\nor run as a Docker container:\n\n```bash\ndocker run -v $(pwd):/app drevops/shellvar [command] [options] path/to/script.sh\n```\n\n## Usage - Lint\n\n- Report on shell variables that are not in `${VAR}` format.\n- Fix shell variables that are not in `${VAR}` format.\n\n### Lint file or directory\n\n```bash\n./shellvar lint path/to/script.sh\n\n./shellvar lint path/to/dir\n\n./shellvar lint --extension=sh --extension=bash --extension=bats path/to/dir\n```\n\nExample:\n\n```bash\n./shellvar lint tests/phpunit/Fixtures/unwrapped.sh\n\n./shellvar lint tests/phpunit/Fixtures\n\n./shellvar lint --extension=sh --extension=bash --extension=bats tests/phpunit/Fixtures\n```\n\n### Fix file or directory\n\n```bash\n./shellvar lint --fix path/to/script.sh\n\n./shellvar lint --fix path/to/dir\n\n./shellvar lint --fix --extension=sh --extension=bash --extension=bats path/to/dir\n```\n\nExample:\n\n```bash\n./shellvar lint --fix tests/phpunit/Fixtures/unwrapped.sh\n\n./shellvar lint --fix tests/phpunit/Fixtures\n\n./shellvar lint --fix --extension=sh --extension=bash --extension=bats tests/phpunit/Fixtures\n```\n\n## Usage - Extract\n\nBy default, variable names, descriptions (taken from the comments) and their\nvalues are printed to STDOUT in the _CSV_ format. You can also change the output\nformat to _Markdown table_ or _Markdown blocks_.\n\nGiven the following shell script (\nsee [extended example](tests/phpunit/Fixtures/test-data.sh) used in tests):\n\n```bash\n# Assignment to scalar value.\nVAR1=val1\n# Assignment to another variable.\nVAR2=\"${VAR1}\"\n# Parameter expansion.\nVAR3=${val3:-abc}\n# Parameter expansion with a default value using\n# another variable $VAR3.\n#\n# Continuation of the multi-line comment.\nVAR4=${val4:-$VAR3}\n```\n\n### CSV (default)\n\n```bash\n./shellvar extract path/to/script.sh\n```\n\n```csv\nName;\"Default value\";Description\nVAR1;val1;\"Assignment to scalar value.\"\nVAR2;${VAR1};\"Assignment to another variable.\"\nVAR3;abc;\"Parameter expansion.\"\nVAR4;${VAR3};\"Parameter expansion with a default value using another variable $VAR3.\n\nContinuation of the multi-line comment.\"\n```\n\n### Markdown table\n\n```bash\n./shellvar extract --format=md-table path/to/script.sh\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to see output\u003c/summary\u003e\n\n```markdown\n| Name   | Default value | Description                                                                                                                      |\n|--------|---------------|----------------------------------------------------------------------------------------------------------------------------------|\n| `VAR1` | `val1`        | Assignment to scalar value.                                                                                                      |\n| `VAR2` | `${VAR1}`     | Assignment to another variable.                                                                                                  |\n| `VAR3` | `abc`         | Parameter expansion.                                                                                                             |\n| `VAR4` | `${VAR3}`     | Parameter expansion with a default value using\u003cbr/\u003eanother variable `$VAR3`.\u003cbr/\u003e\u003cbr/\u003eContinuation of the multi-line comment. |\n```\n\nwhich renders as\n\n| Name   | Default value | Description                                                                                                                   |\n|--------|---------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `VAR1` | `val1`        | Assignment to scalar value.                                                                                                   |\n| `VAR2` | `${VAR1}`     | Assignment to another variable.                                                                                               |\n| `VAR3` | `abc`         | Parameter expansion.                                                                                                          |\n| `VAR4` | `${VAR3}`     | Parameter expansion with a default value using\u003cbr/\u003eanother variable `$VAR3`.\u003cbr/\u003e\u003cbr/\u003eContinuation of the multi-line comment. |\n\n\u003c/details\u003e\n\n### Markdown blocks\n\n```bash\n./shellvar extract --format=md-blocks path/to/script.sh\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to see output\u003c/summary\u003e\n\n```markdown\n### `VAR1`\n\nAssignment to scalar value.\n\nDefault value: `val1`\n\n### `VAR2`\n\nAssignment to another variable.\n\nDefault value: `${VAR1}`\n\n### `VAR3`\n\nParameter expansion.\n\nDefault value: `abc`\n\n### `VAR4`\n\nParameter expansion with a default value using\u003cbr/\u003eanother variable `$VAR3`.\n\nContinuation of the multi-line comment.\n\nDefault value: `${VAR3}`\n\n```\n\nwhich renders as\n\n\u003ctable\u003e\u003ctr\u003e\u003ctd\u003e\n\n### `VAR1`\n\nAssignment to scalar value.\n\nDefault value: `val1`\n\n### `VAR2`\n\nAssignment to another variable.\n\nDefault value: `${VAR1}`\n\n### `VAR3`\n\nParameter expansion.\n\nDefault value: `abc`\n\n### `VAR4`\n\nParameter expansion with a default value using\u003cbr/\u003eanother variable `$VAR3`.\n\nContinuation of the multi-line comment.\n\nDefault value: `${VAR3}`\n\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003c/details\u003e\n\n#### Advanced: Markdown blocks with links and custom template\n\n```bash\n./shellvar extract --format=md-blocks --md-link-vars --md-block-template-file=path/to/template.md path/to/script.sh\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to see output\u003c/summary\u003e\n\n```markdown\n### `VAR1`\n\nAssignment to scalar value.\n\nDefault value: `val1`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR2`\n\nAssignment to another variable.\n\nDefault value: `${VAR1}`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR3`\n\nParameter expansion.\n\nDefault value: `abc`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR4`\n\nParameter expansion with a default value using\u003cbr/\u003eanother\nvariable [`$VAR3`](#VAR3).\n\nContinuation of the multi-line comment.\n\nDefault value: `${VAR3}`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n```\n\nwhich renders as\n\n\u003ctable\u003e\u003ctr\u003e\u003ctd\u003e\n\n### `VAR1`\n\nAssignment to scalar value.\n\nDefault value: `val1`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR2`\n\nAssignment to another variable.\n\nDefault value: `${VAR1}`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR3`\n\nParameter expansion.\n\nDefault value: `abc`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n### `VAR4`\n\nParameter expansion with a default value using\u003cbr/\u003eanother\nvariable [`$VAR3`](#VAR3).\n\nContinuation of the multi-line comment.\n\nDefault value: `${VAR3}`\n\nPath: `1.sh`\n\nPaths: `1.sh`\n\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003c/details\u003e\n\n### Column manipulation\n\nControl the order and visibility of columns in tabular output formats (CSV and Markdown table).\n\n#### Reorder columns\n\n```bash\n./shellvar extract --format=csv --column-order=\"Description,Name\" path/to/script.sh\n```\n\nThis will output columns in the order: Description, Name, Default value (unspecified columns are appended).\n\n#### Show only specific columns\n\n```bash\n./shellvar extract --format=md-table --only-columns=\"Name,Description\" path/to/script.sh\n```\n\nThis will output only the Name and Description columns.\n\n#### Exclude columns\n\n```bash\n./shellvar extract --format=csv --exclude-columns=\"Default value\" path/to/script.sh\n```\n\nThis will output all columns except \"Default value\".\n\n#### Combine column options\n\n```bash\n./shellvar extract --format=csv --only-columns=\"Name,Description,Default value\" --column-order=\"Description,Name\" path/to/script.sh\n```\n\nThis will first filter to only the specified columns, then reorder them.\n\n### Options\n\nThere are options for different phases: extraction, filtering and formatting.\n\n\"Multiple values allowed\" means that you can specify the option multiple times\nlike so: `--exclude-prefix=VAR1 --exclude-prefix=VAR2` etc.\n\n#### Extraction\n\n| Name                               | Description                                                                          | Default value |\n|------------------------------------|--------------------------------------------------------------------------------------|---------------|\n| `paths`                            | File or directory to scan. Multiple files separated by space.                        |               |\n| `--skip-text=SKIP`                 | Skip variable extraction if the comment has this specified text.                     | `@skip`       |\n| `--skip-description-prefix=PREFIX` | Skip description lines that start with the provided prefix. Multiple values allowed. |               |\n\n#### Filtering\n\n| Name                       | Description                                                                                                   | Default value |\n|----------------------------|---------------------------------------------------------------------------------------------------------------|---------------|\n| `--exclude-local`          | Remove local variables.                                                                                       |               |\n| `--exclude-prefix=PREFIX`  | Exclude variables that start with the provided prefix. Multiple values allowed                                |               |                                                                                                               |\n| `--exclude-from-file=FILE` | A path to a file that contains variables to be excluded from the extraction process. Multiple values allowed. |               |\n\n#### Format\n\n| Name                               | Description                                                                                                                                                                                              | Default value                                                    |\n|------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|\n| `--format=FORMAT`                  | The output format: CSV (`csv`), Markdown table (`md-table`), Markdown blocks (`md-blocks`).                                                                                                              | `csv`                                                            |\n| `--sort`                           | Sort variables in ascending order by name.                                                                                                                                                               |                                                                  |\n| `--unset`                          | A string to represent a value for variables that are defined but have no set value.                                                                                                                      | `UNSET`                                                          |\n| `--fields=FIELDS`                  | Semicolon-separated list of fields. Each field is a key-label pair in the format \"key=label\". If label is omitted, key is used as label.                                                                 | `name=Name;default_value=\"Default value;description=Description` |\n| `--path-strip-prefix=PREFIX`       | Strip the provided prefix from the path.                                                                                                                                                                 |                                                                  |\n| `--csv-separator=SEPARATOR`        | Separator for the CSV output format.                                                                                                                                                                     | `;`                                                              |\n| `--column-order=COLUMNS`           | Comma-separated list of column names to specify output order. Columns not specified are appended in their original order. Only applies to tabular formats (csv, md-table).                               |                                                                  |\n| `--only-columns=COLUMNS`           | Comma-separated list of column names to include. Only these columns will appear in output. Only applies to tabular formats (csv, md-table).                                                              |                                                                  |\n| `--exclude-columns=COLUMNS`        | Comma-separated list of column names to exclude from output. Only applies to tabular formats (csv, md-table).                                                                                            |                                                                  |\n| `--md-link-vars`                   | Link variables within usages to their definitions in the Markdown output format.                                                                                                                         |                                                                  |\n| `--md-link-vars-anchor-case`       | The case of the anchors when linking variables. Can be one of \"preserve\", \"lower\" or \"upper\".                                                                                                            | `preserve`                                                       |\n| `--md-no-inline-code-wrap-vars`    | Do not wrap variables to show them as inline code in the Markdown output format.                                                                                                                         |                                                                  |\n| `--md-no-inline-code-wrap-numbers` | Do not wrap numbers to show them as inline code in the Markdown output format.                                                                                                                           |                                                                  |\n| `--md-inline-code-extra-file=FILE` | A path to a file that contains additional strings to be formatted as inline code in the Markdown output format. Multiple values allowed.                                                                 |                                                                  |\n| `--md-block-template-file=FILE`    | A path to a Markdown template file used for Markdown blocks (md-blocks) output format. `{{ name }}`, `{{ description }}`, `{{ default_value }}` and `{{ path }}` tokens can be used within the template. |                                                                  |\n\n## Maintenance\n\n    composer install\n    composer lint\n    composer lint:fix\n    composer test\n    composer build\n\n### Docker publishing\n\nShellvar\nis [published as a Docker image](https://hub.docker.com/r/drevops/shellvar) with\nthe following tags:\n\n- `XX.YY.ZZ` tag - when release tag is published on GitHub.\n- `latest` - when release tag is published on GitHub.\n- `canary` - on every push to `main` branch\n\n---\n_This repository was created using the [Scaffold](https://getscaffold.dev/) project template_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexskrypnyk%2Fshellvar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexskrypnyk%2Fshellvar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexskrypnyk%2Fshellvar/lists"}