Threads for Crestwave

  1. 7

    I’ve basically stopped trying to use the desktop versions of electron apps like discord; I just use the website. For that matter, I have the server portion of element-web running in a docker container on my laptop just so I don’t have to run an electron process for it.

    There’s obviously something compelling about being able to package up a web app as a “desktop app,” but I’m wondering if the desktop browsers supporting the various technologies that go under the heading of PWAs wouldn’t be a better fit.

    This doesn’t necessarily go for things like vscode, which actually do things that aren’t just talk to a web server. But even there, it’d be nice not to have to spawn a whole separate browser.

    1. 2

      That’s not helpful for many of us as the web app lacks the single most important feature - push to talk.

      1. 3

        You can set up a local mic mute push-to-talk hotkey which solves this issue and works for all programs on your computer.

        1. 1

          honestly it boggles my mind that people sell microphones that don’t have this implemented in hardware. what the hell people.

        2. 1

          I’m not sure such a feature could work in Wayland, as it requires a global hotkey. Perhaps it would be ideal to have it as a system function instead, where your microphone device is muted unless you hold the key.

      1. 1

        Not to disparage the effort, but I’m curious why the author has chosen to implement an X11 compatibility layer and not a Wayland one, since X is rapidly approaching obsolescence in the Linux space.

        1. 23

          since X is rapidly approaching obsolescence in the Linux space

          This is said a lot, but it isn’t really true.

          1. 3

            This is said a lot, but it isn’t really true.

            But it should be. X is …… old. It should be resting.

            1. 18

              Linux is only about seven years younger than X. I guess it must be approaching obsolescence too.

              For that matter, I was released in 1986….. oh dear, I don’t think my retirement account is ready for that :(

              1. 13

                Personally I can’t believe lobster.rs is served primarily via TCP and UDP. They are 42 years old and should be put to rest.

                </s>

                1. 1

                  You’re right. We should be using SCTP instead.

            2. 11

              The author explained this here.

              1. 9

                Even if Wayland does finally replace Xorg for Linux users, it doesn’t necessarily mean people will stop wanting to run X11 applications.

                1. 7

                  X was obsolete, full stop, a decade or two ago. Whether or not a thing is obsolete has little to do with how ubiquitous or useful it is.

                1. 7

                  It seems that recently Dylan has disappeared off the radar, I don’t know what the situation is but I wish him well.

                  He was burnt out; it has happened several times, though he’s never gone this far before. But don’t worry, he’s been back for a while and is doing well now, resuming his normal activities.

                  Why is printf used here, and not the arguably simpler echo?

                  Adding on to what you mentioned, echo is hairy and cannot output a variable robustly. For example, try var="-n"; echo "$var".

                  There is no way to turn off interpretation of option arguments—echo does not support -- unlike pretty much everything else. It’s just overall a mess and thus, many shell programmers just use printf no matter what the situation. It’s everything echo is not.

                  In any case, while it’s clear what this is and how it works, it remains to me somewhat of a mystery as to why the particular instance used in the main function here works, where all three expressions are null ((;;)).

                  It’s nothing Bash-specific; it’s just how a C-style for loop works. As the comment hints at, it was the de-facto construct for infinite loops in C, before while (true) even existed. Vintage!

                  1. 4

                    i still use for (;;) in homage.

                    1. 1

                      A good reason to use specific syntax, in my book.

                    2. 1

                      Lovely, thanks for the insights!

                    1. 4

                      Some notes:

                      • #!/bin/sh would probably be even more reliable than #!/usr/bin/env sh
                      • pipefail in set -euf pipefail is useless; it simply sets the first parameter ($1) to “pipefail”. pipefail is a Bashism that is set with -o pipefail.
                      • You inconsistently switch between $HOME and ~
                      • tail -1 is obsolete and no longer specified by POSIX; use tail -n 1 instead
                      • You can use cat 1 2 3 instead of cat 1 2 | cat - 3
                      • sed 's/$/<br>/' doesn’t remove newlines as far as I know; it just prepends <br> before every newline

                      Subjective notes:

                      • You can use printf '\nDone!\n' instead of echo; echo "Done!"
                      • You can use a single command for the help output (and lines 23-25 in install.sh) instead of echoing each line individually; if you want to keep the indentation, you can use cat <<-EOF
                      • You can also combine several cp invocations into one, but it looks fine the current way, I guess
                      • You can use tail -c 1 file instead of tail -c 1 <file
                      1. 3

                        Perhaps I shouldn’t pay it much mind, but I’m not a fan of the “juicy gossip” section:

                        After 25 years he finally stepped away from leadership on the Linux kernel in part, we’re told, precisely to address his pattern of vicious verbal abuse toward other technologists.

                        I find this a bit misleading as it doesn’t mention that it was only temporary.

                        On “renames don’t matter”: I think renames matter, but more importantly, so does Linus. … I found five commits exclusively or chiefly devoted to renaming a command or a module in git itself. If Linus really thought renames didn’t matter, he wouldn’t rename things.

                        It’s a reminder: what people say in this industry often won’t hold up to research.

                        I don’t think he was saying that renames themselves literally don’t have any use; he was saying that tracking renames doesn’t matter to him. After all, he also said that “files don’t matter” and he created an entire kernel based on the concept that everything is a file. :P

                        1. 5

                          I was using BeOS as my daily operating system in the early 2000 and really miss it. It was fast, looked great and some of the core ideas like using BeFS as the database and have translators available to all applications to load and save data in different formats is still unmatched. They really got the right abstractions at the system level, and in a way, it makes we wish we would get beyond the file-based UNIX to introduce more structured primitives (a graph maybe?) as core to the operating system.

                          1. 4

                            Have you checked out Haiku?

                            1. 1

                              Yes, definitely, but things have moved on since then and it sadly doesn’t match the Gnome desktop for my needs. I wish that in an alternate universe, BeOS had continued to evolve over the last 20 years.

                          1. 4

                            Cool! On the other hand, this is a lot longer of a command than grep foo

                            docker run --rm -v "${PWD}:/home/repo" returntocorp/semgrep --lang python --pattern '$X == $X' test.py
                            
                            1. 1

                              For programs that run in Docker, it’s handy to wrap the boilerplate in a shell function. For example, you might stick something like this in your Bash or ZSH startup script.

                              semgrep() {
                                docker run --rm -v "${PWD}:/home/repo" returntocorp/semgrep "$@"
                              }
                              

                              Then running your example looks a little better:

                              semgrep --lang python --pattern '$X == $X' test.py
                              
                              1. 1

                                Wouldn’t an alias be more appropriate? But yes, a function works fine.

                                1. 1

                                  I think the alias wouldn’t be able to interpolate the working directory into the volume mount with -v "${PWD}:/home/repo".

                                  1. 1

                                    It can; why wouldn’t it?

                            1. 4

                              I worked on a similar thing quite recently, and a lot of thinking went into how to avoid evaluation some fragments twice.

                              It didn’t even come to my mind that some may consider evaluating things twice to be not anything but a bug.

                              I guess it’s the power of status quo, which is why it’s always helpful to ask “if it didn’t work that way, would we make it work that way” before going on pointless tangents (like this debate).

                              1. 3

                                I can see the logic here:

                                1. x < f() < z desugars to x < f() && f() < z.
                                2. If f() is evaluated twice, that’s simple but unintuitive.
                                3. If f() is evaluated once, we have to enforce that somehow.
                                4. If we miss a case, now it’s complex and unintuitive, because now it behaves as you expect it to expect for that specific special case, when it’s evaluated twice.
                                5. Maybe it’s safer to just make it always evaluate twice so people always know what they’re getting into.
                                1. 6

                                  I think there are a few problems with that:

                                  x < f() < z desugars to x < f() && f() < z

                                  • If we need to look at the desugaring to understand what it does, maybe we shouldn’t have that syntax sugar in the first place?
                                  • Why make the language worse with additional syntax if you could just write the “desugared” syntax down and be done with it?

                                  If f() is evaluated once, we have to enforce that somehow.

                                  I’m not sure what you mean with that. If the function invocation is written down once it needs to be evaluated once. You simply implement that. It’s pretty much straight-forward, as f() is guaranteed to be stand-alone, not something like this.

                                  Maybe it’s safer to just make it always evaluate twice so people always know what they’re getting into.

                                  Then go ahead and also re-evaluate switch-case for every match-arm, right?

                                   // how often foo() is evaluated is determined the number of cases below
                                  switch foo() {
                                    case x
                                    case y
                                    ...
                                  }
                                  
                                  1. 1

                                    I based that chain of thinking off your claim that

                                    I worked on a similar thing quite recently, and a lot of thinking went into how to avoid evaluation some fragments twice.

                                    If you have to worry about evaluating some fragments twice, then the reasoning makes sense. If that isn’t a problem, then it doesn’t.

                                    (I’m not saying I agree with the chain, I’m saying that I can see how a person would think of double-evaluation as the ‘right behavior’.)

                                  2. 4

                                    x < f() < z desugars to x < f() && f() < z.

                                    Actually, according to the documentation, that would desugar to something like tmp = f(); x < tmp && tmp < z (pseudocode). The expression is only evaluated once, but the value can be fetched twice, which causes the problem with things like tied scalars but not ordinary subroutines.

                                1. 2

                                  The following is not safe:

                                  var=$(dirname "$f")

                                  I…I had no idea! I was pretty sure I was safe because I rely so heavily on shellcheck.

                                  1. 1

                                    Has anyone ever actually seen a file with a newline in the name?

                                    I mean this breaks with spaces at the end too but that also seems pretty oddball naming

                                    1. 4

                                      Has anyone ever actually seen a file with a newline in the name?

                                      Yes. It was in the home directory of an entirely non-technical user – I don’t think save dialogs and other such file-naming GUI bits would generally allow that to hapen, so I’m not really sure how it could have arisen (perhaps an email attachment or web download with an externally-supplied filename?), but one day there it was, breaking things that assumed it wouldn’t be there…

                                      1. 3

                                        I don’t write a ton of code, but when I must, I make a deliberate choice not to try to catch every conceivable corner case. Instead, I put my focus on explicitly catching and dealing with the most likely ways that things might go wrong, and sanitize data only where it absolutely must be sanitized. (And further, there is something to be said as well for maintaining a sane data set, but that’s a can of worms for another day.)

                                        Sometimes this irritates my co-workers. For example, when writing to a file in Python, there are a bunch of things that can go wrong. But I don’t need to check for all of them, because Python has exceptions built in and it will tell you when something unexpected happened by throwing an exception. Wtih an informative traceback and everything. It’s all built right into the language! All the programmer really has to do is make sure that data is not destroyed when Something Bad happens. And maybe post a “whoops, something went wrong message” if the program is being executed by a non-technical user, at the very worst.

                                        1. 2

                                          What you are noting is that there is a cost in readability, maintenance, and likelihood of mistakes in dotting every single i.

                                          Sometimes, that cost might be worth paying. Sometimes, the cure is worse than the disease.

                                        2. 3

                                          Has anyone ever actually seen a file with a newline in the name?

                                          On purpose? No. By accident? Yes.

                                          1. 1

                                            Probably, but this only breaks with a newline at the end, which seems way less likely to me.

                                            1. 1

                                              well technically var=$(dirname "$f") will break with whitespace anywhere, because the call isn’t quoted. But var="$(dirname "$f")" would only break with it at the end, yes.

                                              1. 2

                                                It won’t, actually; word splitting and globbing don’t apply to variable assignments. It doesn’t apply to word in case word in either.

                                                1. 1

                                                  Huh, learn something new every day.

                                        1. 16

                                          I find all the admonishments to use POSIX shell rather than bash befuddling. Why would you not want to use Bash language features such as arrays and associative arrays? If your goal was portability across a wide swath of UNIX variants, then I understand that you might want to target POSIX shell, but that is a very unusual goal. In most instances why not leverage a shell language with very useful features?

                                          1. 32

                                            Because arrays and associative arrays are two of the most broken features in bash. You can use them if you’re an expert, but your coworker who has to maintain the script will likely not become an expert. (I’ve been using shell for 15 years and implementing a shell for 4, and I still avoid them)

                                            I implemented them more cleanly in Oil and some (not all) of the differences / problems are documented here.

                                            https://www.oilshell.org/release/latest/doc/known-differences.html

                                            • ${array} being equivalent to ${array[0]} is very confusing to people. Strings and arrays are confused.
                                            • associative arrays and arrays are confused. Try doing declare -A array and declare -a assoc_array and seeing what happens.
                                            • dynamic parsing of array initializers is confusing and buggy
                                            • in bash 4.3 and below (which is deployed on Ubuntu/Debian from 2016, not that old), empty arrays are confused with unset arrays (set -e). Not being able to use empty arrays makes them fundamentally broken

                                            I could list more examples, but if you’ve used them even a little bit, you will run into such problems.

                                            In Oil arrays and assoc arrays are usable. And you even have the repr builtin to tell you what the state of the shell is, which is hard in bash.


                                            edit: I forgot that one of the first problems I wrote about is related to array subscripts:

                                            Parsing Bash is Undecidable

                                            Also the security problem I rediscovered in 2019 is also related to array subscripts:

                                            https://github.com/oilshell/blog-code/tree/master/crazy-old-bug

                                            A statement as simple as echo $(( a )) is in theory vulnerable to shell code injection.

                                            • Shells that do not have arrays do not have the security problem.
                                            • You can inject code into shells with arrays with a piece of data like a[$(echo 42; rm -rf /)].

                                            All ksh derived shells including bash have this problem. Note that you don’t even have to use arrays in your program to be vulnerable to this. Simply using arithmetic in a shell that has arrays is enough! Because arithmetic is dynamically parsed an evaluated, and accepts $(command subs) in the array index expression.

                                            https://unix.stackexchange.com/questions/172103/security-implications-of-using-unsanitized-data-in-shell-arithmetic-evaluation/172109#172109


                                            bash is poorly implemented along many dimensions, but I would say arrays are one of the worse areas. But I learned that it got a lot of that bad behavior from ksh, i.e. “bash-isms” are really “ksh-isms”. So the blame for such a bad language to some extent goes back to AT&T and not GNU.

                                            1. 2

                                              Thanks. Without arrays, how do recommend handling cases where you need to build up a series of arguments to be passed to another command?

                                              1. 4

                                                I oscillate between:

                                                • Using strings and implicit splitting for known/trusted arguments. If you’re building up flags to a compiler like -O3 or -fsanitize=address, this is a reasonable option, and the one I use.
                                                • Using arrays and taking care not to use empty arrays (which is annoying).

                                                The fact that it’s awkward is of course a motivation for Oil :)

                                              2. 1

                                                in bash 4.3 and below (which is deployed on Ubuntu/Debian from 2016, not that old), empty arrays are confused with unset arrays (set -e). Not being able to use empty arrays makes them fundamentally broken

                                                Did you mean set -u? And to be fair, I would consider this more of a case of set -u being broken; it seems that their fix for it was to not trigger (even when unset) on * and @ indexes.

                                                1. 1

                                                  Yes set -u. Either way, you can’t use empty arrays and “strict mode” together, which makes arrays virtually useless in those recent version of bash IMO.

                                                  I have a memory of running into that the first time, and I couldn’t understand what was going on. And I ran into many more times after that, until I just stopped even trying to use arrays.

                                              3. 15

                                                Why would you not want to use Bash language features such as arrays and associative arrays?

                                                If you need them that’s a good sign it’s time to rewrite the script in real programming language.

                                                1. 13

                                                  It’s not as “unusual” as you might think though. There are many people running OpenBSD on their work machines, where bash is simply not included in the default install. I could see why you’d want to make your script work without issue when bash isn’t an option. At the very core, a shell script should not do much: cleanup your local mailbox, aggregate multiple RSS feeds or perform a quick backup using rsync, … I have run openbsd on a laptop for some time, and I was delighted to see that all my personnal scripts were still working like a charm (besides calls to seq(1), this one killed me…). I’ve also written some simple C software, and wrapper scripts for it using POSIX shells only, and I was glad that nobody from the BSD world bothered me with these scripts.

                                                  Another argument is that POSIX shells is much more simple to use and understand than the myriad of corner-cases and specificities that bash can have. It sure is a strengh to be able to use proper arrays, but bash manpage has 5 times more (48746 words) than sh (10224). Mastering bash as a language is definitely harder than sticking to POSIX, especially when you only write scripts that are < 20 lines.

                                                  1. 5

                                                    Even on Linux bash isn’t always included by default, especially on simple server setups/distros such as Alpine Linux.

                                                    The seq thing is annoying, BSD has jot with different syntax. I wish they could agree on one or the other. Same with stat.

                                                  2. 11

                                                    In my experience, the moment my shell script becomes complex enough for a bash array is the moment it gets rewritten in Python.

                                                    The only features from bash that have convinced me to require it in recent memory are herestrings (<<<) and the regex match operator (=~).

                                                    1. 1

                                                      In my experience, the moment my shell script becomes complex enough for a bash array is the moment it gets rewritten in Python.

                                                      Same here. Even for the simple scripts since a script would become more complicated over time.

                                                    2. 4

                                                      I use systems without bash installed by default. If you’re going to write a complex script that is too awkward to write in POSIX sh, then why not use a better (less quirky) language in the first place? Python for example is probably available in almost as many places as bash now. If you’re writing a shell script, you’re probably aiming for portability anyway, so please write POSIX shell if you can.

                                                      1. 2

                                                        I write many bash scripts where portability is not a concern and I think the language can be quite functional and even elegant when you are pulling together different cli tools into a new program.

                                                        1. 3

                                                          Ubuntu shaved quite a bit off their (pre-systemd) boot times by just switching /bin/sh from bash to dash (although I can’t find the exact number right now). The increased performance may be a concern (or is at least nice) in some cases (bending over backwards for it would of course be silly).

                                                          1. 2

                                                            Certainly if it’s not a concern and you enjoy the language then I don’t see a problem with using bash! My main issue is that I don’t think it’s at all an unusual goal to use POSIX sh for portability.

                                                          2. 1

                                                            Because there are plenty of use cases, like installers, where relying on another language isn’t possible.

                                                            1. 4

                                                              Why not do the heavy lifting in awk, if your’e in such a restricted environment?

                                                              1. 1

                                                                When I talk about writing shell applications, I personally am talking about using bash plus all the standard UNIX tools that come with every UNIX base install.

                                                                Awk is one of those tools.

                                                                1. 5

                                                                  And when I say do the heavy lifting in awk, I mean more or less ignore the shell, and use awk. You get proper arrays, reasonable syntax for writing algorithms, relatively little shelling out, relatively sane string manipulation, and sidestep a bunch of issues around shell variable reexpansion.

                                                                  And your code is more portable.

                                                                  1. 2

                                                                    I believe that. I haven’t used awk that way and I’ll admit that’s because I don’t know it well enough.

                                                                    I know I’m asking a lot but might you be able to link to an example of awk being used in this way?

                                                                    I mostly end up using stupid simple awk invocations like awk ‘{print $3}’ :)

                                                                    1. 1

                                                                      Here’s an example from the FreeBSD tree. Lines 107 through 788 are one big awk script. https://github.com/freebsd/freebsd/blob/master/sys/kern/makesyscalls.sh

                                                                      It parses the syscall definitions here, and generates C: https://github.com/freebsd/freebsd/blob/master/sys/kern/syscalls.master

                                                              2. 1

                                                                Why isn’t it possible and why can’t it be done in POSIX sh?

                                                                1. 1

                                                                  The OP’s post has two points.

                                                                  1. If you’re writing anything complex at all, use a different language.

                                                                  That’s what I was addressing.

                                                                  To your point, there are customer environments where shipping UNIX systems with languages like Python is prohibited, either because of security constraints, maybe disk usage, etc.

                                                                  1. bash versus POSIX shell? If bash ships as /bin/sh on a given UNIX system, I don’t see the difference as important enough to be worth any gymnastics to get one installed, but you may have a higher dimensional understanding of the differences than I do.
                                                                  1. 1

                                                                    I don’t think it’s really a big issue. Certainly for myself it’s only a minor frustration if I need to install bash for a simple script which gains nothing from using bash. I’ve just seen the #!/bin/bash shebang far too many times when it’s not necessary, and I think that a lot of the time that’s just because people don’t know the difference. It’s certainly not the end of the world and if bash feels like the right tool for whatever your use case is then I’m not going to argue! It would just be nice if there was a little awareness of other systems and that people would default to #!/bin/sh and only consider bash if they find a specific need for it. I imagine that in most cases shell scripts are used there actually is no need.

                                                                    I’m a little obsessed with building my workflow around shell scripts and I have never found a need for bash extensions (YMMV). The other big benefit other than portability as others have suggested is the digestibility of the manpages for, e.g. dash.

                                                          1. 2

                                                            It is perhaps a bit disingenuous to call this 8 lines of Bash when the first line is 399 characters long and separates commands with semicolons; you can put basically any script in “one line” with this. The only reason this isn’t in one is probably because they didn’t want to use extra bytes for the newlines in the output.

                                                            That said, this is cool; I just found the title misleading. :) Fun fact: if I remember correctly, this was basically pfetch, but was superseded by the POSIX sh version and turned into a golf.

                                                            1. 4

                                                              Just want to note that Haiku has standard directories such as ~/config/settings, and programs are patched to use them! Of course, it’s still in beta and all, but it’s cool that they’re taking action on this. :)

                                                              1. 2

                                                                It is inherited from the Plan9.

                                                              1. 9

                                                                Hello, it’s one of mine once again.

                                                                Please let me know if you come across any bugs. I (and a few others) use this daily to chat in #kisslinux on Freenode.net which is also the default server/channel birch will connect to (come say hi!).

                                                                I’m still working on a man page and extending the documentation (keybinds and commands are documented). A proper tagged release will come once this is done.

                                                                For those wondering “WHY?”, this was a lot of fun. Minus single calls to fold and tail and some file operations, birch is entirely implemented in pure bash. Down the line I’d like to reduce the external command calls solely to file operations (if at all possible).

                                                                I hope you enjoy it!

                                                                1. 3

                                                                  I’ve added more thorough documentation to the README. Creation of the man page is next. Let me know if you still have any questions. ;)

                                                                  1. 3

                                                                    This is beautiful, nice work. I don’t really use IRC but I’ll use it tmrw!

                                                                    1. 3

                                                                      This is great. I was shocked to see how few lines of code it is, especially given that it’s bash.

                                                                      1. 2

                                                                        Awesome!

                                                                        If you want maximum KISS, rewriting in POSIX shell would be fun…

                                                                        1. 3

                                                                          rewriting in POSIX shell

                                                                          in bash ? 😁

                                                                          1. 3

                                                                            POSIX sh != bash. Bash has several incompatible extensions on top of POSIX sh. See the man page for checkbashisms.

                                                                            1. 4

                                                                              I know, that’s exactly the point of the joke!

                                                                            2. 1

                                                                              Don’t make me flag this comment “troll”… ;)

                                                                              1. 3

                                                                                I didn’t mean to troll at all ! It’s a joke as I know Dylan for rewriting many existing tool using bash constructs only, so he could decide to make his own shell using the language he likes the most 😉

                                                                            3. 3

                                                                              POSIX shell doesn’t have /dev/tcp and such, though; it would have to rely heavily on external utilities.

                                                                          1. 3

                                                                            What’s the point of the installed function testing if it’s a regular file? Couldn’t you just use something like hash "$1" 2>/dev/null or command -v "$1" >/dev/null 2>&1?

                                                                            1. 1

                                                                              Oh, it seems to be to try to exclude aliases and such; hash works for that, or if you also want to exclude builtins, type -P "$1" >/dev/null.

                                                                            1. 4

                                                                              This says Bash, but isnt that POSIX sh?

                                                                              1. 2

                                                                                Yes, but Bash is compatible with POSIX sh and the author may not have known that the script was only using POSIX sh features.

                                                                              1. 2

                                                                                !didIMakeAMistake() || CIsWrongHere();

                                                                                If you understand how short-circuit evaluation works, you can understand that this will result in the following:

                                                                                if (!didIMakeAMistake()) CIsWrongHere();

                                                                                Wouldn’t that be if (didIMakeAMistake()) CIswrongHere(); or am I missing something?

                                                                                1. 2

                                                                                  (edit to emphasize I support your statement, and you are correct)

                                                                                  In f(A) || g(B) g(B) is only evaluated if f(A) is false. If f(A) were true, there is no need to evaluate g(B) since the expression as a whole is going to be True no matter what. This is something to look out for when you have functions with side effects.

                                                                                  #include <iostream>
                                                                                  
                                                                                  
                                                                                  int side_effect = 0;
                                                                                  
                                                                                  
                                                                                  bool f(int x) {
                                                                                      return x > 2;
                                                                                  }
                                                                                  
                                                                                  
                                                                                  bool g(int x) {
                                                                                      side_effect = 1;
                                                                                      return x > 1;
                                                                                  }
                                                                                  
                                                                                  int main()
                                                                                  {
                                                                                      int x = 2;
                                                                                      if (f(x) || g(x)) {
                                                                                          std::cout << "Hello!" << std::endl;
                                                                                      }
                                                                                  
                                                                                      std::cout << side_effect << std::endl;
                                                                                  
                                                                                      return 0;
                                                                                  }
                                                                                  

                                                                                  You can change the value of x from 2 to 3 to see what happens. Try it out here: https://onlinegdb.com/SJMH13XRB

                                                                                  1. 1

                                                                                    Yes, you are completely right, thank you.

                                                                                  1. 1

                                                                                    The nice thing about pash is that it is so simple that it is easy to modify, and more importantly, it can read the pass password store – You simply have to set the right path.

                                                                                    By the way, does any one seriously use the list command? It prints a tree, which is totally hostile to grep. Here is my fork that changes it to simply list things instead (and moves the original list to tree) which makes it easy to search using grep.

                                                                                    1. 2

                                                                                      Your fork shows the tree output above the fold in the readme.

                                                                                      1. 1

                                                                                        Are you dylanaraps? If so thank you for adding it! (Btw: Why did you choose to use find instead of shell globs?)

                                                                                        1. 1

                                                                                          I am not, as others have said.

                                                                                          1. 1

                                                                                            No, he isn’t. I haven’t used this program yet, but POSIX shell globs can’t match things recursively.

                                                                                            1. 1

                                                                                              Oh OK, good to know. At the time I forked, he was still using globs, so was simply using the same style.

                                                                                              1. 1

                                                                                                Yes, that was before he rewrote it in POSIX sh (from Bash). ** is globstar, which is Bash-specific.

                                                                                      1. 2

                                                                                        I’ve written something similar for my personal use – pw.

                                                                                        1. 1

                                                                                          I know that this might not be too polished because it’s for personal use, but why the mixed use of printf and echo? You can also use herestrings (<<<string) to redirect a string to a command’s stdin in Bash. Also, you might want to print error messages from die to stderr (>&2).

                                                                                          1. 1

                                                                                            Ah yes, thanks for pointing out those inconsistencies. I’ll fix it.

                                                                                        1. 10

                                                                                          I’m not touching an operating system without even an attempt at package signing with a ten-foot pole, “simplicity” be damned.

                                                                                          1. 1

                                                                                            But it’s a source-based distro; you build the packages.

                                                                                            1. 2

                                                                                              I don’t build them from thin air, though; I build them from package sources provided by the distribution. I can’t verify the integrity of those sources any other way than downloading them from GitHub and assuming they’re intact. Gentoo is source-based as well, but ebuilds still come with manifests containing checksums ultimately signed with PGP. Trusting the master repository is not a sufficient security model on its own. I probably don’t have to remind you that even GitHub can be compromised, and in fact, has been in the past.

                                                                                              And yes, of course I could verify the integrity of my package sources by reviewing them before building, but honestly, if I have to review the package build files that come straight from my upstream distro maintainers for security breaches, I’m really left scratching my head over why I’m using the distro in the first place.

                                                                                              1. 1

                                                                                                Signature verification has now been integrated into the package manager! https://github.com/kisslinux/kiss/issues/60#issuecomment-538341425

                                                                                                1. 1

                                                                                                  The author agreed and is now signing all commits from now. The integration of signature verifying to the package manager is tracked here; he’s deemed GnuPG 1.4 simple enough to include in the base system if the issues mentioned are resolved.

                                                                                                  1. 1

                                                                                                    Well, the distro isn’t for everyone. But you do have a point; commits could be signed without impacting the simplicity of the base system, then you could at least optionally set up your system to verify it. I’ve brought it up with the author.

                                                                                              1. 4

                                                                                                Package manager written in POSIX sh

                                                                                                busybox ash

                                                                                                shellcheck

                                                                                                I see a problem here. Ash doesn’t support arrays (and shellcheck will enforce that word splitting is not used as a substitute). While that may be adequate in some special cases, it’s a straitjacket I generally wouldn’t want to be programming in.

                                                                                                The reason I wrote a guide called how to do things safely in bash specifically, and not in POSIX shell in general, is that there are things (like common things) that just can’t be done correctly in POSIX shell.

                                                                                                1. 2

                                                                                                  I see a problem here. Ash doesn’t support arrays (and shellcheck will enforce that word splitting is not used as a substitute).

                                                                                                  Positional parameters are used for arrays; ShellCheck’s warnings are disabled temporarily when intended. Think of it like Rust’s unsafe: you can use it safely, you just have to be careful as you’re on your own there. Globbing is, of course, disabled when this is done.

                                                                                                  The package system’s design is also compatible with POSIX shell: each type of entry has a separate file (e.g., checksums) and has one entry per line. So it can be easily looped over by redirecting it into a while read loop.

                                                                                                  The reason I wrote a guide called how to do things safely in bash specifically, and not in POSIX shell in general, is that there are things (like common things) that just can’t be done correctly in POSIX shell.

                                                                                                  Yes, the author is experienced in Bash; he’s the author of Neofetch, Pure Bash Bible, fff, etc.

                                                                                                  The final blow is that fighting such an abstraction failure of the language is pointless if you can choose a different language.

                                                                                                  POSIX shell has advantages, though; in this case, it’s minimal and part of BusyBox. Bash is completely incompatible with the base system’s philosophy with its bloat, however great it might be, so you can’t simply choose it here.

                                                                                                  1. 2

                                                                                                    Solid answer. Thanks.

                                                                                                    I still think that someone needs to fork Busybox/Ash and add array support. It probably wouldn’t add much bloat (since it already supports one array – the positional parameters, as you mentioned).

                                                                                                    That would remove this unnecessary burden on the responsible programmer to select $IFS carefully (which is not generally possible!), turn off globbing and reason about safety on their own.

                                                                                                    And with that goes (AFAIK) the only unachievable aspect of shellcheck compliance. Ash would move from bad™ to good™ on my list.

                                                                                                    1. 2

                                                                                                      KISS is designed to be minimal and substitutable, though, so the package manager is going for full POSIX compliance, and it seems unlikely for POSIX to implement that. The author did mention that arrays were the main thing he missed from Bash.

                                                                                                    2. 2

                                                                                                      Think of it like Rust’s unsafe: you can use it safely, you just have to be careful as you’re on your own there.

                                                                                                      Safe Rust has robust support for iteration, though. It isn’t utterly crippled.

                                                                                                      1. 1

                                                                                                        Yes, safe Rust is much more powerful overall than POSIX sh; that’s not the point of my analogy.