[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Add {{ }}, ${{ }}, return n [x], and $:
From: |
konsolebox |
Subject: |
Add {{ }}, ${{ }}, return n [x], and $: |
Date: |
Fri, 30 Apr 2021 14:53:58 +0800 |
I think these features are worth adding:
{{ }} - Similar to { }, but runs like a function so variables can be
declared local
return n [x] - Assigns n to $? and x to $: if specified
${{ }} - Executes like {{ }} but also expands to the value of $:
$: will be reset to an empty string at the beginning of any
non-assignment execution context. The string can be a constant static
for the sake of efficiency.
Alternatively, $. can be used instead of $:.
I discarded the idea of returning arrays since it would be inefficient
to reassign and confusing to expand. People should just use named
references or a temporary global for that. Return by string is ok
since it makes ${{ }} a bit similar to $( ).
The greatest goal of these features is to help eradicate the
inefficient var=$(echo "returned value") practice people do. Second
would be so I'm sure I don't unset a global variable when unsetting an
iterator in an initialization script to keep the variables clean, even
just by theory.
--
konsolebox
- Add {{ }}, ${{ }}, return n [x], and $:,
konsolebox <=
- Re: Add {{ }}, ${{ }}, return n [x], and $:, Robert Elz, 2021/04/30
- Re: Add {{ }}, ${{ }}, return n [x], and $:, konsolebox, 2021/04/30
- Re: Add {{ }}, ${{ }}, return n [x], and $:, Robert Elz, 2021/04/30