[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] compgen -V option (store output in array)
From: |
Koichi Murase |
Subject: |
Re: [PATCH] compgen -V option (store output in array) |
Date: |
Thu, 13 Apr 2023 17:57:04 +0900 |
2023年4月13日(木) 17:31 Grisha Levit <grishalevit@gmail.com>:
> Since the predominant use case for compgen is generating output that then
> gets split back up into an array, it seems like it would be nice to have an
> option that avoids the extra steps (and their associated pitfalls)
I have related but unsubmitted patches that I made before. I attach
them. This adds a new flag option `-z` that makes the output of
`compgen' separated by NUL This is useful when we want to process the
candidates of compgen (that may contain newlines as a part of a
candidate) using external commands such as `sort -z'. Also, now we can
load a NUL-separated stream in an array by « mapfile -d '' ».
Currently, there is no way to distinguish the newlines as a part of
candidates from the newlines that are used to separate candidates. The
option name `-z' could be alternatively `-0' or any other as far as it
works.
The first patch `r0034.compgen-update-desc.patch' update the
description of existing options in manuals before adding the
description of the new option. The patch `r0034.compgen-zflag.patch'
adds the option -z.
These are related discussions in bash-completion and ohmybash:
https://github.com/scop/bash-completion/issues/704#issuecomment-1091631732
https://github.com/ohmybash/oh-my-bash/issues/341#issuecomment-1168073038
https://github.com/scop/bash-completion/pull/765#issuecomment-1173097965
I'd be glad if both `-z' and `-V' could be added in `compgen'.
--
Koichi
r0034.compgen-update-desc.patch
Description: Binary data
r0034.compgen-zflag.patch
Description: Binary data