Skip to content

Commit

Permalink
Fixed incorrect handling of options to sed. A sed filter would break
Browse files Browse the repository at this point in the history
if the script part (which follows the options string) contained a double
hyphen (`--`) surrounded by one or more spaces.
  • Loading branch information
linguisticmind committed Jun 20, 2024
1 parent dfb150f commit 5ddd332
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
<th>Date</th>
<th>Description</th>
</tr>
<tr>
<td>
<a href='https://github.com/linguisticmind/pretty-declare-print/releases/tag/v0.1.6'>0.1.6</a>
</td>
<td>
2024-06-20
</td>
<td>
Fixed incorrect handling of options to <code>sed</code>. A <code>sed</code> filter would break if the script part (which follows the options string) contained a double hyphen (<code>--</code>) surrounded by one or more spaces.
</td>
</tr>
<tr>
<td>
<a href='https://github.com/linguisticmind/pretty-declare-print/releases/tag/v0.1.5'>0.1.5</a>
Expand Down
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@ Video tutorial:
</tr>
<tr>
<td>
<a href='https://github.com/linguisticmind/pretty-declare-print/releases/tag/v0.1.5'>0.1.5</a>
<a href='https://github.com/linguisticmind/pretty-declare-print/releases/tag/v0.1.6'>0.1.6</a>
</td>
<td>
2024-06-01
2024-06-20
</td>
<td>
<p>
<b>IMPORTANT</b>: Fixed a bug where the closing parenthesis of an array consisting of a single element wouldn't get printed when breaking up arrays into multiple lines was disabled (<code>-M, --no-multiline-arrays</code>).
</p>
<p>
Now, <code>-c, --color / -C, --no-color</code> also affects colorization of the output in names mode.<br>
<code>bat</code>'s <code>--paging</code> is now always set to <code>never</code> in names mode.
</p>
<p>
Fixed formatting in the CHANGELOG file.
</p>
Fixed incorrect handling of options to <code>sed</code>. A <code>sed</code> filter would break if the script part (which follows the options string) contained a double hyphen (<code>--</code>) surrounded by one or more spaces.
</td>
</tr>
</table>
Expand Down Expand Up @@ -489,7 +480,7 @@ COPYRIGHT
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

PRETTY-DECLARE-PRINT 0.1.5 2024 PRETTY-DECLARE-PRINT(1)
PRETTY-DECLARE-PRINT 0.1.6 2024 PRETTY-DECLARE-PRINT(1)
```
## License
Expand Down
2 changes: 1 addition & 1 deletion man/man1/pretty-declare-print.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH PRETTY-DECLARE-PRINT 1 2024 PRETTY-DECLARE-PRINT\ 0.1.5
.TH PRETTY-DECLARE-PRINT 1 2024 PRETTY-DECLARE-PRINT\ 0.1.6

.SH NAME
pretty-declare-print \- prettify output of `declare -p`
Expand Down
4 changes: 2 additions & 2 deletions pretty-declare-print
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

version=0.1.5
version=0.1.6

getopt -T > /dev/null
[[ $? != 4 ]] && { printf '[%s] %s\n' "${BASH_SOURCE##*/}" 'Enhanced getopt is required to run this script.' >&2; exit 1; }
Expand Down Expand Up @@ -507,7 +507,7 @@ printf '%s\0%s\n%s\n' "$lib_dir" "$(declare -p opt_sort_associative_arrays opt_m
[[ $arg ]] && sed_opts+=("$arg")
done < <(<<<"${sed_script%%+([[:space:]])--+([[:space:]])*}" xargs printf '%s\0')
fi
sed_script="${sed_script##*+([[:space:]])--+([[:space:]])}"
sed_script="${sed_script##+([[:space:]])--+([[:space:]])}"
data=$(<<<"$data" sed "${sed_opts[@]}" "$sed_script")
done
printf '%s\n' "$data"
Expand Down

0 comments on commit 5ddd332

Please sign in to comment.