Open airtonix opened 6 months ago
One
number one on my wtf list is this:
#!/bin/sh ':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@" console.log('Hello world');
I understand this part:
$(command -v nodejs || command -v node)" "$0" "$@"
- if there's a command on called nodejs, or node, then
- execute the current file "$0" with whatever args were passed originally "$@"
but the part I'm not entirely understanding is
':' //;
:
':'
i get that this is just a string so bash does nothing with it?// ;
???? lmao wut?Second
this lead me to be think about the experience editing this file:
- because it ends in
.sh
, or- because there's no vim modelines,
There's no automatic correct syntax highlighting (whole file is considered bash so shellcheck screams about everything)
So the second question is did you try this instead:
- rename the file to rofi-search.js (now the file gets automatic syntax highlighting regardless of the editor)
- change the hashbang to
#!/usr/bin/env node
(now the js file will execute with nodejs)My only assumption is that you're trying to account for ubuntu users that incorrectly have nodejs installed via apt as nodejs.
but the part I'm not entirely understanding is ':' //; : ':' i get that this is just a string so bash does nothing with it? // ; ???? lmao wut?
Its the part that makes it syntactically valid both in shell and javascript at the same time. Explanation here: https://unix.stackexchange.com/questions/65235/universal-node-js-shebang
My only assumption is that you're trying to account for ubuntu users that incorrectly have nodejs installed via apt as nodejs.
yes #!/usr/bin/env node
would fail if users have installed nodejs
via apt.
Since this project is not updated often, compatibility has had bigger priority. if needed, I set the syntax highlighting manually in vim.
At the time of creating this I wanted just single file that could be executed everywhere.
One
number one on my wtf list is this:
I understand this part:
$(command -v nodejs || command -v node)" "$0" "$@"
but the part I'm not entirely understanding is
':' //;
:':'
i get that this is just a string so bash does nothing with it?// ;
???? lmao wut?Second
this lead me to be think about the experience editing this file:
.sh
, orThere's no automatic correct syntax highlighting (whole file is considered bash so shellcheck screams about everything)
So the second question is did you try this instead:
#!/usr/bin/env node
(now the js file will execute with nodejs)My only assumption is that you're trying to account for ubuntu users that incorrectly have nodejs installed via apt as nodejs.