awesome-dotfiles icon indicating copy to clipboard operation
awesome-dotfiles copied to clipboard

[Feature Request] Some scripts are incompatible with the fish shell

Open e-sam opened this issue 4 years ago • 8 comments

Summary

As we have discovered in #31, some of the scripts are not working, if the default shell is fish. Unfortunately, this also affects the network widget and possibly other areas, that I haven't noticed yet. Especially, in the network widget, the differences between fish and bash are so big, that I doubt, it will be possible to write a version, that runs in both shells. Therefore my proposal would be, to have two versions of the script and use the SHELL environment variable, to choose the script corresponding to the users login shell.

Example

An example of the big differences between bash and fish I mentioned earlier:

# Bash
if [[ -n "${$wireless}" && -d "${net}${wireless}" ]]; 
then
  ...
fi

# Fish
if test -n "$wireless" && test -d "$net$wireless"
  ...
end

Points to discuss

  • Is there really no way to write a script that runs in both shells?
  • Should we try, to auto detect the users current shell, e.g. by using the SHELL environment variable, or rather have a variable, in rc.lua, where the user can change the shell manually?
  • Should we keep the scripts inside the lua files, or move them to dedicated shell files, to make things a bit cleaner?
    • Downside of this could be, that you have to make the scripts executable after cloning the repository

Once we have come to a conclusion about the above points, I am willing to create a pull request, containing the network manager and everything else, I discover until then, in a version working with fish.

e-sam avatar Jan 01 '21 13:01 e-sam

Thank you for the generous offer and detailed write up! I'm going to spend some time this evening researching this to see if there's a shell agnostic way to achieve the functionality we want here, and come up with an implementation plan accordingly, I'll keep this issue updated on the progress.

WillPower3309 avatar Jan 01 '21 19:01 WillPower3309

I think I have found a pretty neat solution. We could pipe the scripts to bash, this would mean you need to have bash installed to make the scripts work, but it doesn't have to be your default shell.

Examples:

echo 'pgrep -u $USER -x %s > /dev/null || (%s)' | bash -
echo 'a longer script' | bash -

e-sam avatar Jan 02 '21 09:01 e-sam

I think I have found a pretty neat solution. We could pipe the scripts to bash, this would mean you need to have bash installed to make the scripts work, but it doesn't have to be your default shell.

Examples:

echo 'pgrep -u $USER -x %s > /dev/null || (%s)' | bash -
echo 'a longer script' | bash -

Thats a super elegant solution! I was having a hard time finding a fix so thank you for the idea, I think that is the route we should go down to fix it. I'll be implementing this tonight

WillPower3309 avatar Jan 02 '21 16:01 WillPower3309

Great! I'm glad I could help. Thanks again for the nice themes

e-sam avatar Jan 02 '21 20:01 e-sam

commit 02c706b fixes the startup issues, however fixing the network widget will be more time intensive. It's a mess of lua string formatting and single and double quotes clashing when trying to add echo ' command ', so I will be trying to tackle that beast over the next few days. Pull requests are welcome if anyone can finish before then but for now the startup behavior is fixed

WillPower3309 avatar Jan 04 '21 02:01 WillPower3309

Got a very important interview late next week so ill be putting this off until after then, apologies to anyone waiting. The startup is working now, just need to finish the network widget

WillPower3309 avatar Jan 07 '21 19:01 WillPower3309

@WillPower3309 if you're still interested in fixing this, instead of piping commands to bash, you could set awful.util.shell to bash, which would force the awful.spawn.*_with_shell functions to spawn a bash shell instead of fish, avoiding the requirement to manually pipe to bash each time (and the interim fish shell), as well as making quoting easier.

aarondill avatar Nov 08 '23 03:11 aarondill

@WillPower3309 if you're still interested in fixing this, instead of piping commands to bash, you could set awful.util.shell to bash, which would force the awful.spawn.*_with_shell functions to spawn a bash shell instead of fish, avoiding the requirement to manually pipe to bash each time (and the interim fish shell), as well as making quoting easier.

That's great to know, thanks! I'll see if I can get that fixed up

WillPower3309 avatar Nov 08 '23 20:11 WillPower3309