5 ms·
What is this doing in the first example in the readme? > open https://api.github.com/repos/lmorg/murex/issues https://api.github.com/repos/lmorg/murex/issues
by abhibeckert 3y ago
What is this doing in the first example in the readme?
> open https://api.github.com/repos/lmorg/murex/issues https://api.github.com/repos/lmorg/murex/issues
As a Mac user, I'd expect that to launch a web browser, but it appears to be downloading and parsing the JSON?
- latexr 3y agoNote how the line ends with a backslash. That is escaping the newline so the command isn’t executing immediately. The next line begins with a pipe which is taking the input. It’s a way of separating multiple piped commands over several lines for readability. In other words, these are equivalent: echo 'Something or other' | sed 's/or/and/' and echo 'Something or other' \ | sed 's/or/and/'
- alexgrover 3y agoI think the point they’re trying to make is that the “open” command does something very different than the Mac builtin
- vram22 3y agoIIRC, in this case, backslashes are not needed. You can just end each partial line of such long commands with a pipe sign and keep writing the rest of the overall command on subsequent lines, except for the last partial line, where you just press Enter to complete and run it.
- hnlmorg 3y agoThere is a Murex builtin with the same name: https://murex.rocks/docs/commands/open.html https://murex.rocks/docs/commands/open.html This naming conflict is actually one of my regrets within Murex. I was a couple of years into development on this shell before I obtained a mac test system. I think most of the Murex users in the early days were also Linux users too. So I wasn't aware of the conflict until there was already too much code written in Murex to be worth the risk renaming the builtin. However can mitigate this by running `exec open ...` -- you can set that as an alias as well, eg alias o=exec open
- still_grokking 3y agoThat has nothing to do with Macs. `open` is an alias for `xdg-open`. At least on Debian and derivatives (so around on 9x% of all Linux boxes).
- hnlmorg 3y agoThat's not the same thing. On macOS it is a Mach-O executable: » file ${which open} /usr/bin/open: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e] /usr/bin/open (for architecture x86_64): Mach-O 64-bit executable x86_64 /usr/bin/open (for architecture arm64e): Mach-O 64-bit executable arm64e Whereas on Linux it is a shell alias. Doesn't appear to be universal either (doesn't exist on Arch, for example). It was a recent change too, added to Debian 11 (released 2021), which is years after it was added to Murex. As an aside, I wouldn't be at all surprised if the `open` alias was added to Debian to copy (and I mean this affectionately) macOS. Otherwise `xdg-open` might have just been called `open` from the beginning.
- still_grokking 3y agoI'm not sure what this comment want's to tell us. There is the same command function wise on Debian Linux. Alias or not makes no difference. Debian Linux is the base of almost all Desktop Linux boxes out there. (There are of course niche distris, but the overwhelming majority is Debian based; I count Ubuntu as Debian based.) There is nothing "specific" to my shell environment. Having the `open` alias available the default. I would need to change things manually to diverge form this default. That would be "specific to my shell environment", not the other way around. Historically `open` comes form NextStep, so actually Apple copied it. On Linux it's usually a symlink as there are other implementations then the one in `xdg-utils`, and there have been also other programs with that name in the past.
- hnlmorg 3y agoI think you're being a little unfair here: First of all you describe it as an alias, which is very different to a symlink. A symlink is a file so will be available system wide. Whereas an alias is only available to shells that have had that alias added to (and it's pretty common for embedded shells, like in IDEs, to not pick up default aliases). So my points were about aliases not symlinks. For what it's worth "open" doesn't exist on my Ubuntu servers either. And it was added to Debian only 2 years ago. Murex has been around for nearly a decade. So I can hardly be blamed for adding a builtin with the same name as something that hadn't yet been added to Linux. > Historically `open` comes form NextStep, so actually Apple copied it. Apple didn't copy NextStep, they bought it and ported/rebranded a lot it's tech. Also I wasn't claiming Apple invented the concept of "open". I was saying I suspect Debian got the idea from macOS. --- Anyway, this is all moot because the `open` builtin (Murex) already checks if `open` is a TTY (ie you're not piping the output of `open`). You can define how commands get opened when it's a TTY as well https://www.murex.rocks/docs/commands/openagent.html https://www.murex.rocks/docs/commands/openagent.html -- this is how Murex can inline images into the terminal -- so i can just add a "if no open agent is defined fallback to exec open" type condition. Then everyone is happy. As to why `open` builtin reinvents `xdg-open` -- well that's because Murex needed something cross platform and there wasn't a reliable way to do that at the time. So I had to roll my own. Now the landscape has changed somewhat, I daisy chain the builtin to call the system `open` command on supporting platforms.
- still_grokking 3y ago> > open https://api.github.com/repos/lmorg/murex/issues https://api.github.com/repos/lmorg/murex/issues > As a Mac user, I'd expect that to launch a web browser As a Linux user I would expect the exact same thing.