Open orefalo opened 1 year ago
$()
doesn't create a subshell. In this instance your echo $(a)Gb
code is correct.
Regarding printf
, as it happens this is something I'm planning on adding at some point too. The main reason I've held off it thus far is because I suspect it might be a pretty big piece of work and printf
is already available as an external executable (in fact it is a required part of POSIX https://en.wikipedia.org/wiki/List_of_Unix_commands) so it's only Windows systems that would be unsupported. This means when I do embark on a printf
builtin, I have to ensure that it is at least as functional as GNU and BSD printf otherwise the builtin would become an anti-feature for most people.
working on the doc, I found this hidden command:
out nono -> sprintf "%10s"
murex » builtin sprintf
Error in `fexec` (0,1): no builtin exists with the name `sprintf`
for some reason it is not recognized as a builtin.
mind sharing more details about it? I would solve the formatting issues I was trying to resolve originally. worth adding to the documentation?
It's a very old function and only available on POSIX. I've been meaning to deprecate it to be honest because it's not that useful and the murex printf
builtin, whenever it gets written, would absorb the one useful aspect of it (to read from STDIN)
if you type sprintf
into the terminal then press [F1]
you'll see the code behind it.
this may help, I found an implementation in golang https://github.com/moxtsuan/printf
Unfortunately there isn't a license file on there. Plus the project doesn't appear to be maintained.
I've had a thought about printf
in Murex though, it might not be a big a piece of work as I first assumed. In fact I've already started prototyping some code on it.
Describe the problem: Ability to format strings with variables.
While trying to port some of my scripts, I am seeing limitations with the
out
built-in In particular, the ability to output a value and string, without a space delimiter, and the formatting.for instance
This last one worked, at the expense of a subshell.
Formatting, allows for instance to strip the .33 from the 55; or to display the value as hex, fp..etc
Maybe the implementation of a builtin similar to fish would be beneficial.
Additional context:
Fish has the
printf
built-in, https://fishshell.com/docs/current/cmds/printf.htmlfor instance