{"id":23640571,"url":"https://github.com/sigpwned/bashsubstitution4j","last_synced_at":"2025-11-10T01:30:19.230Z","repository":{"id":269863785,"uuid":"908057799","full_name":"sigpwned/bashsubstitution4j","owner":"sigpwned","description":"A Bash-style substitution library for Java 8+","archived":false,"fork":false,"pushed_at":"2025-02-01T19:19:16.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T20:25:15.574Z","etag":null,"topics":["bash","bash-substitution","java","java-8"],"latest_commit_sha":null,"homepage":"https://github.com/sigpwned/bashsubstitution4j","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigpwned.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-12-25T02:30:18.000Z","updated_at":"2025-02-01T19:19:19.000Z","dependencies_parsed_at":"2024-12-26T18:34:30.268Z","dependency_job_id":"77e0c00f-c11c-4e6b-ae10-ed738e62de2e","html_url":"https://github.com/sigpwned/bashsubstitution4j","commit_stats":null,"previous_names":["sigpwned/bashsubstitution4j"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fbashsubstitution4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fbashsubstitution4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fbashsubstitution4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fbashsubstitution4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigpwned","download_url":"https://codeload.github.com/sigpwned/bashsubstitution4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576790,"owners_count":19662114,"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","bash-substitution","java","java-8"],"created_at":"2024-12-28T09:26:54.699Z","updated_at":"2025-11-10T01:30:19.104Z","avatar_url":"https://github.com/sigpwned.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bashsubstitution4j [![tests](https://github.com/sigpwned/bashsubstitution4j/actions/workflows/tests.yml/badge.svg)](https://github.com/sigpwned/bashsubstitution4j/actions/workflows/tests.yml)\n\nA Bash ([Bourne Again SHell](https://www.gnu.org/software/bash/)) substitution library for Java 8+.\n\nThis library is intended as a *very* simple templating library with familiar syntax. It is explicitly *not* intended as a full Bash implementation, or to perform anything more than basic string manipulation. More specifically, the library does not (and will not ever) create new processes, access the file system, print to stdout/stderr, etc.\n\n## Features\n\nThe library supports the following Bash substitution features:\n\n* Parameter expansion\n* String globbing\n* Indirection (e.g., `${!parameter}`)\n\nThe library does not currently support the following Bash substitution features, but may in the future:\n\n* Arithmetic expansion\n* Quoting\n* Arrays\n* Namerefs\n* Extglob\n\nThe library does not currently support the following Bash substitution features, and never will:\n\n* Tilde expansion, since it accesses system environment facts\n* Command substitution, since it creates new processes\n* File globbing, since it access the file system\n\n## Supported substitutions\n\n* `${parameter}`\n* `${parameter:-word}`\n* `${parameter:+word}`\n* `${parameter:offset}`\n* `${parameter:offset:length}`\n* `${parameter#word}`\n* `${parameter##word}`\n* `${parameter%word}`\n* `${parameter%%word}`\n* `${parameter/pattern/string}`\n* `${parameter//pattern/string}`\n* `${parameter/#pattern/string}`\n* `${parameter/%pattern/string}`\n* `${parameter^pattern}`\n* `${parameter^^pattern}`\n* `${parameter,pattern}`\n* `${parameter,,pattern}`\n* `${parameter@operator}`, for operators `UuL`\n* `${!parameter}` (indirection, for all of the above)\n\n## Quick start\n\nTo perform substitution using environment variables, use:\n\n    BashSubstitution.substitute(System.getenv(), \"This is my ${ADJECTIVE} template.\");\n\nTo perform substitution using system properties, use:\n\n    BashSubstitution.substitute(System.getProperties(), \"This is my ${ADJECTIVE} template.\");\n\nTo perform substitution using custom variables, use:\n\n    Map\u003cString, String\u003e customVariables=new HashMap\u003c\u003e();\n    customVariables.put(\"ADJECTIVE\", \"fancy\");\n    BashSubstitution.substitute(customVariables, \"This is my ${ADJECTIVE} template.\");\n\n## Advanced usage\n\nUsers can create an instance to perform many substitutions with a given set of variables and use it like this:\n\n    BashSubstitutor substitutor=new BashSubstitutor(System.getenv());\n    String substitution = substitutor.substitute(\"This is my ${ADJECTIVE} template.\");\n\nUsers can translate a Bash (string) globbing expression using:\n\n    // Use true for greedy globbing, or false for non-greedy globbing\n    Pattern p = StringGlobbing.toJavaPattern(globExpression, false);\n\n### Disabling syntax\n\nBy default, the `BashSubstitutor` class supports all the enumerated substitutions. If users want not to support some specific syntax, then they can simply create a new subclass overriding a specific expression type. For example:\n\n    // Don't support the ${parameter#word} syntax\n    BashSubstitutor substitutor = new BashSubstitutor(variables) {\n        @Override\n        protected CharSequence handleHashExpr(CharSequence name, CharSequence pattern) {\n            throw new UnsupportedOperationException(\"syntax not supported\");\n        }\n    };\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigpwned%2Fbashsubstitution4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigpwned%2Fbashsubstitution4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigpwned%2Fbashsubstitution4j/lists"}