Hi Dan
How about « fc -ln » ?
It might be helpful to have explicit cross-references between the help
displays for «history» and «fc».
-Martin
On Sun, 24 Mar 2024 at 15:40, Dan Jacobson wrote:
> $ help history
> should mention how in the world one is supposed to just print the plain
> history,
On Thu, Mar 21, 2024 at 4:08 PM Chet Ramey wrote:
>
> On 3/20/24 3:05 PM, Zachary Santer wrote:
>
> > it's more work
> > than if there were three separate parameter transformations. one each
> > to always generate a declare command; an assignment statement; and the
> > right hand side of a compoun
On Fri, Mar 22, 2024 at 11:23 AM Chet Ramey wrote:
>
> This is what you can do with @K.
>
> https://lists.gnu.org/archive/html/bug-bash/2021-08/msg00119.html
>
> Word splitting doesn't happen on the rhs of an assignment statement, so you
> use eval. The @K quoting is eval-safe.
Yeah, but what can
On Sunday, March 24, 2024, Zachary Santer wrote:
>
> Yeah, but what can you do with @k?
It helps when reconstructing an associative array as a JSON object in JQ
$ declare -A a=([x]=1 [y]=2)
$ jq --args -n '[$ARGS.positional | _nwise(2) | {(.[0]): .[1]}] | add'
"${a[@]@k}"
{
"y
On Sun, Mar 24, 2024 at 01:04:38PM -0400, Zachary Santer wrote:
> On Fri, Mar 22, 2024 at 11:23 AM Chet Ramey wrote:
> >
> > This is what you can do with @K.
> >
> > https://lists.gnu.org/archive/html/bug-bash/2021-08/msg00119.html
> >
> > Word splitting doesn't happen on the rhs of an assignment
On Sun, Mar 24, 2024 at 07:46:46PM +0200, Oğuz wrote:
> On Sunday, March 24, 2024, Zachary Santer wrote:
> >
> > Yeah, but what can you do with @k?
>
>
> It helps when reconstructing an associative array as a JSON object in JQ
>
> $ declare -A a=([x]=1 [y]=2)
> $ jq --args -n '[$ARGS.po
On Sunday, March 24, 2024, Greg Wooledge wrote:
> Conceptually that looks great, but how do you avoid "Argument list
> too long" with larger inputs?
$ declare -A a=([x]=1 [y]=2)
$ printf '%s\0' "${a[@]@k}" | xargs -0 jq --args -n '$ARGS.positional |
_nwise(2) | {(.[0]): .[1]}' | jq -s a
On Sunday, March 24, 2024, Oğuz wrote:
>
> $ printf '%s\0' "${a[@]@k}" | xargs -0 jq --args -n '$ARGS.positional
> | _nwise(2) | {(.[0]): .[1]}' | jq -s add
>
On reflection, splitting by NULs in JQ is better; there is no guarantee
that xargs will always provide an even number of arguments.
On Sun, Mar 24, 2024, at 2:56 PM, Greg Wooledge wrote:
> On Sun, Mar 24, 2024 at 01:04:38PM -0400, Zachary Santer wrote:
>> On Fri, Mar 22, 2024 at 11:23 AM Chet Ramey wrote:
>> >
>> > This is what you can do with @K.
>> >
>> > https://lists.gnu.org/archive/html/bug-bash/2021-08/msg00119.html
>> >
On Sun, Mar 24, 2024 at 1:56 PM Greg Wooledge wrote:
> It would be pretty reasonable to have a builtin that could take an array
> name plus any number of additional argument pairs, and load those pairs
> as keys/values into said array. Then you could do something like this:
>
> declare -A ha
On Sun, Mar 24, 2024 at 03:54:10PM -0500, Dennis Williamson wrote:
> The @K transform outputs key value pairs for indexed arrays as well as
> associative arrays (you used the @k transform which does word splitting and
> loses the k-v sequence).
The @K (capital) transformation gives you quoted stri
On Sun, Mar 24, 2024 at 4:04 PM Greg Wooledge wrote:
> The @K (capital) transformation gives you quoted strings which need to
> be eval'ed. Very Bourne-shell-ish.
>
> The @k (lowercase) transformation gives you a list of alternating raw
> key/value strings, like what you'd expect from a Tcl comm
> "MDK" == Martin D Kealey writes:
MDK> How about « fc -ln » ?
I like it!
P.S.,
$ help fc
-nomit line numbers when listing
Yes, it omits the line numbers. But leaves the "^I " separators!
$ fc -l 999 1000|cat -vt
999^I echo invite Nerbleson for dinner
1000^I echo and Snordsw
On Sun, Mar 24, 2024, at 8:54 PM, Dan Jacobson wrote:
> Yes, it omits the line numbers. But leaves the "^I " separators!
>
> $ fc -l 999 1000|cat -vt
> 999^I echo invite Nerbleson for dinner
> 1000^I echo and Snordsworth too
> $ fc -ln 999 1000|cat -vt
> ^I echo invite Nerbleson for dinner
> ^I ech
How unfortunate.
P.S., "\t%s" seems to have an extra space squeezed between them with bash: "\t
%s",
unless perhaps the spec says that %s always starts with a space.
On Sat, Mar 23, 2024 at 11:34 AM A4-Tacks wrote:
>
> ```bash
> $ ((!RANDOM))
> bash: !RANDOM: event not found
> ```
I just reported this last August [1]. If you, like me, never use
history expansion, the best solution might be to disable it in your
.bashrc file:
set +o histexp
On Sun, Mar 24, 2024, at 11:01 PM, Dan Jacobson wrote:
> P.S., "\t%s" seems to have an extra space squeezed between them with
> bash: "\t %s",
> unless perhaps the spec says that %s always starts with a space.
The standard doesn't say that, so in native mode bash's `fc' is
indeed slightly nonconf
Hmm, so no matter POSIX mode or not, both will be dragging around that
little piece of toilet paper stuck to their shoes (\t)... unless some
new option is invented.
18 matches
Mail list logo