TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
5.07k stars 176 forks source link

hostname -s is not portable to Solaris #23

Closed mgrubb closed 7 years ago

mgrubb commented 8 years ago

a more portable solution would be to either use: $(hostname | sed -e 's/..$//') or since you are depending on bash: hostname=$(hostname) hostname=${hostname%%.} though the first option is more concise

TheLocehiliosan commented 8 years ago

Interesting, I didn't know this about Solaris. I hope you didn't somehow set your hostname to -s.

I've pushed a commit to the exp experimental branch. Let me know if this version seems to work for you.

mgrubb commented 8 years ago

Well, I have come across this before when writing my own scripts and wondering why my hostname kept changing to '-s' on solaris :) so I thought I would pass along my experience proactively.

ThomasAdam commented 8 years ago

This will happen on Linux as well.

TheLocehiliosan commented 8 years ago

@ThomasAdam I'm curious about which Linux distros do not support the -s parameter. Regardless, the change I've made will be universal—so this should end up working everywhere.

spcutrell commented 7 years ago

I can help by adding that it doesn't work with Void Linux.

It looks like the issue is that the "basic" hostname from coreutils doesn't support any options [link].

TheLocehiliosan commented 7 years ago

@spcutrell When you said "it doesn't work with Void Linux", do you mean 1.05 doesn't work because of hostname problems? Or do you mean that the planned 1.06 version (https://github.com/TheLocehiliosan/yadm/commit/ea6291a9866fc5dad84994624d40231acfbd75e2) does not work with Void Linux?

spcutrell commented 7 years ago

Sorry, I should have been more clear. I mean 1.05. I see no reason why 1.06 won't work. I will actually be able to confirm it for you tonight if you'd like.

I was mostly just responding to add more clarity to the problem (why -s doesn't work on some distros) and to give an example of a distro that it didn't work on.

TheLocehiliosan commented 7 years ago

This change is now in the dev branch, staged for 1.06