File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
Oh, didn't know about -c. I usually just pipe to wc -l I guess.
-c, -l, -h, -H, and -q are my favorite #grep flags. :D
Huh, that almost became a [Marcel Duchamp] reference. π
I just use -v and -E
...and bash instead of zsh
...and grep/awk/sed instead of jq
...and firefox instead of chrome
...and the fediverse instead of facebook
Face it... I'm an unpopular-opinion neckbeard level boss. XD
cc: @mirabilos
@rl_dane Those are so not comparable!

@kabel42 I see you also like to see the world burn.

@mirabilos @kabel42 @rl_dane @amin @thedoctor
Legacy is mostly the safe route to go anyway, tried and tested, I am the one that gets called if shit stops working, and I'd rather have something I know and makes sense, with tons of resources of administrators of the before times having struggled with them to help me figure out what is going on. Rather than modern stuff, with their ai documentation, discord "forums" and shipping their whole pc (docker) because they couldn't get their shit to work on a clean system :p
@kabel42 @mirabilos @rl_dane @amin @thedoctor
Hey I relied on that bug!
@sotolf @kabel42 @mirabilos @rl_dane @thedoctor
Oh haha so it was intentional. I was wondering.
@kabel42 @mirabilos @rl_dane @thedoctor @sotolf
Haha, you got it too! XD
@sotolf @kabel42 @mirabilos @rl_dane @thedoctor
Sometimes knowing the right xkcd is like shooting fish in a barrel. (Cruel, but easy.)
@amin @sotolf @kabel42 @mirabilos @thedoctor
That's why I use good old C-x M-c M-spacebarheat ;)
@kabel42 @amin @sotolf @mirabilos @thedoctor
A slant reference to xkcd 378 ;)
@mirabilos @thedoctor @kabel42 @sotolf @amin
ksh got started in... 1983? That's not legacy? XD

@mirabilos @kabel42 @sotolf @thedoctor @amin
Probably because people are addicted to the breakneck pace of "progress," novelty, and chasing their tails.
Maybe I'll spin up a laptop that only runs Unix v4 in a VM to try to spin the earth a tiny bit in the other direction. π
(Likely not)
@rl_dane @thedoctor @kabel42 @sotolf @amin @mirabilos
ksh is a type-safe, memory-safe language supporting modern paradigms like concurrency, higher-order functions and pattern matching. Its standard library even supports distributed applications and serverless architectures as well as microservices.
Not sure what should be legacy about that?
@mirabilos @nik @thedoctor @kabel42 @sotolf @amin
WAT. Sounds amazing, got an example?
Is this mksh or ksh93/2020?
@rl_dane @nik @thedoctor @kabel42 @sotolf @amin ksh2020 is completely gone. Thereβs now βksh93u+mβ by MartΔ³n @mcdutchie as actively-developed version. ([Overview]β¦ which I should update some dayβ¦ oopsβ¦)
This is, for now, an mksh thing; it stems from [a thread] by @navi in which she desires something like that for sh, but I chose to add it to the Korn shell-style function syntax instead because it is easy to add there without breaking anything and because it leaves the POSIX space open for future standardisation.
Itβs deliberately not yet documented in the manpage or so because it can change at will and without prior notice and is, at this point, only something for people to play around with, to get a feeling for it, before it can become standardised.
(Also, I very much dislike the idea of adding it to the () of POSIX-style functions, as that would look too much like a subshell.)
general idea is:
| function (a b=foo) name { β¦ }
β¦ is identical enough toβ¦
| function name {
| a=$1; shift
| if (( $# )); then
| b=$1; shift
| else
| b=foo
| fi
| β¦
| }
Note that default arguments can have side effects (like a parname=[] mutable default argument in Python)β¦
function (count=$((++selfcount_cnt))) selfcount {
echo calling me for the ${count}th time
}
β¦ but they are shortcut-evaluated (i.e. selfcount_cnt will not be incremented if selfcount is called with an argument), like in most logic (if (foo != NULL && foo->bar > 1) would crash if it werenβt).
The [commit message] has some more information, and of course you can read the diffs linked (user=pass public as usualβ¦ fscking LLM scrapersβ¦) for more info, check.t contains some self-tests for this.
gl hf
@mirabilos @nik @thedoctor @kabel42 @sotolf @amin @mcdutchie @navi
That's lovely. π
@mirabilos @rl_dane @nik @thedoctor @kabel42 @sotolf @amin @mcdutchie
(Also, I very much dislike the idea of adding it to the () of POSIX-style functions, as that would look too much like a subshell.)
the main point of the thing was making the posix () not useless though ~w~
subshells arenβt allowed after a word like that in any context i can think of so imo someone would need to really go out of their way to make the syntax look confusing (most often subshells only pop up at the start of a command, or after a pipe, neither of which match function declarations much)
foo(nya mew=beep) {
echo $nya $mew
}
selfcount(count=$((++selfcount_cnt))) {
echo calling me for the ${count}th time
}
iβm not a fan of the side effect thing much, but itβs something i think we should have anyway due to specifying the default value the same as any normal assignment, something like mew=${2-beep}, so count=${1-$((++selfcount_cnt))}
@sotolf @thedoctor @kabel42 @mcdutchie @navi @amin @rl_dane @nik yes, thatβs sort of how it works, except it actually inspects argc I think.
Hmmmm, use of $n (where n is number) in default args could be⦠"interesting". But, I think, possible.
@navi @sotolf @amin @rl_dane @kabel42 @mcdutchie @nik @thedoctor yes, it inspects argc, and it shifts after each, so $1 is always the one in question, though I donβt think you can do anythingn useful with it.
There also is no provision for namerefs yet (and thatβs beyond POSIX and very shell-specific anyway). Might be interesting, perhaps with a prefix before the variable name.
@kabel42 @mirabilos @rl_dane @thedoctor @sotolf
I feel like you're baiting them. XD
@kabel42
I feel like you're rage baiting a little bit π

@pixx @kabel42 @mirabilos @amin @thedoctor @sotolf
Ragebaiting is fun if everyone is in on it. ;)
@sotolf @kabel42 @mirabilos @amin @thedoctor
> ...guess how you configure a command line tool it boots up a web server where you configure it...
*runs screaming for the hills
What the absolute forking fork egad Noooooooo!!!!!!!
@mirabilos @kabel42 @sotolf @amin @thedoctor
He moved from IBM to MS, because IBM wasn't evil enough. π
@kabel42 @mirabilos @amin @sotolf @thedoctor
1. When in doubt, copy Windows.
2. Moar systemd
3. ?!?!?
4. PROFIT!!!
@sotolf @mirabilos @rl_dane @thedoctor
Mmmmm I don't think fish would be mir's thing. XD
@sotolf @thedoctor @rl_dane @mirabilos
Mm, not really though? ripgrep is meant for bulk grepping of files