kdave / btrfsmaintenance

Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag on selected mountpoints or directories.
GNU General Public License v2.0
897 stars 79 forks source link

"echo -n" bashism in /bin/sh scripts #74

Closed automorphism88 closed 4 years ago

automorphism88 commented 5 years ago

The scripts use echo -n to parse the colon-separated paths in the config file. This is a problem if /bin/sh is dash, since -n is taken as part of the string to be echoed and not as an option, and ends up getting prepended to the first path in the list.

As a solution, either the more portable printf should be used in place of echo, or the shebangs should be changed from /bin/sh to /bin/bash.

eku commented 5 years ago

@automorphism88 BTW #!/usr/bin/env bash would be the correct way.

automorphism88 commented 5 years ago

@automorphism88 BTW #!/usr/bin/env bash would be the correct way.

Not necessarily. That approach has both advantages and disadvantages, and if you wanted to use /usr/bin/env, then it might as well be #!/usr/bin/env sh right now, but it isn't.

kdave commented 4 years ago

All scripts have been switched to #!/bin/bash. I've run checkbashisms -n -p to see how many there are, enough to do a simple fix instead for now. All fixable though.