{"id":15748179,"url":"https://github.com/binaryphile/nano","last_synced_at":"2026-04-15T23:32:40.065Z","repository":{"id":143324971,"uuid":"91021226","full_name":"binaryphile/nano","owner":"binaryphile","description":"a nano-sized bash library","archived":false,"fork":false,"pushed_at":"2017-08-22T14:59:56.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T11:31:06.404Z","etag":null,"topics":["bash"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binaryphile.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-05-11T20:36:50.000Z","updated_at":"2022-03-17T20:20:42.000Z","dependencies_parsed_at":"2023-05-14T21:15:46.042Z","dependency_job_id":null,"html_url":"https://github.com/binaryphile/nano","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binaryphile%2Fnano","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binaryphile%2Fnano/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binaryphile%2Fnano/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binaryphile%2Fnano/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binaryphile","download_url":"https://codeload.github.com/binaryphile/nano/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246429447,"owners_count":20775805,"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"],"created_at":"2024-10-04T05:40:50.313Z","updated_at":"2026-04-15T23:32:35.032Z","avatar_url":"https://github.com/binaryphile.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"nano [![Build Status](https://travis-ci.org/binaryphile/nano.svg?branch=master)](https://travis-ci.org/binaryphile/nano)\n====\n\nA nano-sized bash library\n\nDefines a handful of less-visible (with leading underscores) functions\nwhich are useful for writing other libraries.\n\nnano API\n========\n\n-   **`_joina`** *`delimiter array_name return_variable`* - joins the\n    elements of the array `array_name` with the character `delimiter`\n\n*Returns*: the joined string in the variable `return_variable`\n\n`return_variable` must exist outside of your function scope, usually\ndeclared by your function's caller.\n\n-   **`_puts`** *`string`* - prints `string` with a newline\n\n*Returns*: the string, with newline, on stdout\n\nUses the POSIX-recommended `printf` function instead of `echo`. Unlike\n`echo`, `string` must be a single argument.\n\n-   **`_putserr`** *`string`* - prints `string` with a newline to stderr\n\n*Returns*: the string, with newline, on stderr\n\n`string` must be a single argument.\n\n-   **`_ret`** *`return_variable string_value|array_name|hash_name`* -\n    return a value via a named return variable\n\n*Returns*: the value, in `return_variable`\n\n`return_variable` must exist outside of your function scope, usually\ndeclared by your function's caller. The existing variable must also be\nthe appropriate type; scalar, array or hash (a.k.a. associative array).\n\n`return_variable` is therefore usually passed into your function as an\nargument, which is then passed onto `_ret`.\n\nExample:\n\n      myfunc () {\n        return_variable=$1\n\n        local \"$return_variable\" || return\n        _ret \"$return_variable\" 'my value' # pass back a string\n      }\n\nBefore calling `_ret`, your function must also declare `return_variable`\nlocally, as shown. Since the variable name may not be a valid identifier\nstring, this is usually done with a `return` clause in case it errors.\nThis should only be done right before calling `_ret`.\n\nYou could accomplish the same thing without `_ret` by using indirection\nvia `local -n ref` or `${!ref}`, but both of these allow the referenced\nvariable name to conflict with your local variables. `_ret` prevents\nnaming conflicts with your local variables.\n\nCalling `_ret`, however, does unset the named variable in your\nfunction's scope. If the variable name is also used by one of your local\nvariables (always possible), then your variable will be unset. Therefore\nyou may not be able to rely on variables after calling `_ret`, so you\nshould only do so right before your function returns.\n\nThe returned value(s) may be a scalar value, or may be contained in a\nnamed array or hash. If passing an array or hash, simply use the\nvariable name as the second argument. If passing back a scalar value,\nuse the value, not its variable name (if stored in a variable).\n\nAs a corollary, the `_ret` function is unable to pass back the names of\narrays or hashes as scalar values. They will always be passed as their\narray values. Be forewarned.\n\n`_ret` is based on the discussion [here], but is enhanced to pass arrays\nby name.\n\n  [here]: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinaryphile%2Fnano","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinaryphile%2Fnano","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinaryphile%2Fnano/lists"}