1

This question is a follow-up from https://unix.stackexchange.com/questions/126955/percent-in-path-environment-variable. I post it here, since it is more distro-specific.

The shell used by default for sh namely dash, is not compatible with execvp because it fiddles with the $PATH variable. A standardized way of dealing with strange filenames is to use URL encoding scheme. Now I cannot use that standard because dash reserves %. To solve this I problem I have the following options

  1. Recommend my users on Ubuntu to change the symbolic link /bin/sh to something else like bash. It is necessary to do it globally since popen(3) relies on /bin/sh.

  2. Diverge from traditional URL encoding by using something other than %

  3. Throw an error whenever any of the Forbidden characters (yes, Windows but these restriction is sane in a dual-boot configuration) appears.

Ideally I prefer option (1) seems the best way to go. It makes it possible to use a standardized escape scheme in filenames. However, since dash clearly behaves differently than some other shells, it will break the system if any of the system scripts rely on functionality unique to dash. Also it requires that the user has root privileges.

Option (2) implies that I have to find another symbol that does not collide anywhere. Certainly, some shell may screw up any symbol that is not a letter.

Option (3) implies too large reduction in functionality

5
  • What do you mean by "reserves %"? I was able to create a file named %a%b%c and copy it. – choroba Apr 29 '14 at 8:07
  • @choroba See unix.stackexchange.com/questions/126955/… – user877329 Apr 29 '14 at 8:08
  • I don't see why you don't just use bash in your shebang line instead of sh. That would avoid all these problems altogether. – terdon Apr 29 '14 at 10:56
  • @terdon Because there is no shebang. I need popen to run the program. Yes I can use a wrapper script placed somewhere else, but that does not solve the true problem. Or I could modify popen to use bash... – user877329 Apr 29 '14 at 14:21
  • Ah, I see, that makes sense. – terdon Apr 29 '14 at 14:22
1

Option one is fairly simple. You just need to run:

sudo dpkg-reconfigure dash

And pick No. That'll push /bin/sh back to /bin/bash.

You could do this manually (removing the link, creating a new one) but this is the official method.

4
  • exactly how risky is it – user877329 Apr 29 '14 at 8:14
  • I would consider bash a superset of functionality of dash but it honestly isn't that often I consider things that way around. The only way you're going to know is by testing it out... I'd just do it on a non-production system you can restore if it all blows up. – Oli Apr 29 '14 at 8:15
  • It's also worth benchmarking important things before and after if you have time-sensitive operations. Bash is slower and heavier than Dash. – Oli Apr 29 '14 at 8:17
  • After replacing the default shell, the system upstart time is exactly the same. Measured on i5-3570k SATA-3.0 disk. – user877329 Apr 29 '14 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.