Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buggy bash line in README #2

Open
sarna opened this issue May 14, 2019 · 5 comments
Open

Buggy bash line in README #2

sarna opened this issue May 14, 2019 · 5 comments

Comments

@sarna
Copy link

sarna commented May 14, 2019

Hi!

First of all, thanks for writing this tool, it's really helpful :)

However, I noticed (well, my shell noticed) one of your bash lines in the README is wrong. Observe:

sarna@ub:~$ echo 'eval $(lonestar init)' >> "$HOME/.${SHELL}rc"
bash: /home/sarna/./bin/bashrc: No such file or directory

It behaves like this, because

sarna@ub:~$ echo $SHELL
/bin/bash

And that's not what we want!

I searched the web for a bit and found this helpful thread.

These two answers seem to be fitting:

sarna@ub:~$ ps -p $$ -oargs=
bash
sarna@ub:~$ echo $0
bash

I'm no shell expert though, so I'll leave the decision to someone smarter than me :)

Have a nice day!

@Tyil
Copy link
Owner

Tyil commented Jul 11, 2019

First off all, sorry for the slow response!

Interesting find, I had not considered this. I will pick a suitable solution and make a fix for this in the README soon-ish. Thanks!

@Tyil
Copy link
Owner

Tyil commented Jul 11, 2019

I've done some testing on my local machine with bash, dash, fish and zsh. The results are as follows:

  • echo $0

    • bash: bash
    • dash: dash
    • fish: ``
    • zsh: /bin/zsh
  • ps -p $$ -oargs=

    • bash: bash
    • dash: dash
    • fish: No output, but an error instead. Fish doesn't support $$.
    • zsh: /bin/zsh

So it seems this is not the solution either. However, I can make something work with awk in the mix, combined with $SHELL.

  • echo $SHELL|awk -F/ '{print $NF}'
    • bash: bash
    • dash: zsh
    • fish: zsh
    • zsh: zsh

This, however, doesn't seem to work properly for me either. If I come from a zsh shell, and run bash, and then run echo $SHELL|awk -F/ '{print $NF}', it still reports zsh on my machine. Another possible solution I have is using ps, tail and awk.

  • ps -p $$|tail -n1| awk '{print $NF}'
    • bash: bash
    • dash: dash
    • fish: An error, as it still doesn't support $$.
    • zsh: zsh

So, apart from fish, the last solution seems to be most universal. I'm not a fish export (or a proponent of any non POSIX compatible shell), so I guess I'll take this solution. If someone knows a solution that would also work for fish, I'd be happy to hear/read it.

@sarna
Copy link
Author

sarna commented Jul 11, 2019

It would be incorrect for fish anyway, since it doesn't have .fishrc - .bashrc's equivalent is at ~/.config/fish/config.fish.

I'd say push the last solution for now and keep the issue open, I might be able to make some time over the weekend to write a fish-specific version.

@Tyil
Copy link
Owner

Tyil commented Jul 11, 2019

Updated in cb49060.

@sarna
Copy link
Author

sarna commented Jul 20, 2019

Okay, so, I got it to work on FreeBSD using fish. I had to patch the Makefile, though.

Steps to install from source, in my case:
cd (mktemp -d) -- note this line is different from the one in README
git clone https://github.com/tyil/lonestar.git .
apply the Makefile patch
sudo make install clean

Also, lonestar init doesn't work with fish. To properly add stuff to path, fish user can use this:

set -U fish_user_paths ~/.rakudo-star/*/install/bin $fish_user_paths 
set -U fish_user_paths ~/.rakudo-star/*/install/share/perl6/site/bin $fish_user_paths

So - it works, but I don't know which changes you want to incorporate into lonestar :) Feel free to utilize whatever you find useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants