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

Improvements and cleanup #19

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Commits on Oct 24, 2018

  1. gitignore: Ignore common editor backups

    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    e1aa312 View commit details
    Browse the repository at this point in the history
  2. Use consistent file layout

    The current file is mixing tabs and spaces on various indents. Since
    tabs are use the most, I suppose that's what was intended to be used.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    5673854 View commit details
    Browse the repository at this point in the history
  3. Add .editorconfig editor configuration file

    Ensure consistent editing where supported by adding the optional
    .editorconfig. This does not enforce any style and only works if the
    editor supports it (via a plugin for example).
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    a6781cd View commit details
    Browse the repository at this point in the history
  4. Put udevadm in a variable

    By putting udevadm in a variable we only have one place to have the whole
    string, could easily replace it with UDEVADM="$(command -v udevadm)" or
    otherwise.
    
    Furthermore add a test for the executability of the binary.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    6a2bab3 View commit details
    Browse the repository at this point in the history
  5. Depend on systemd (for udevadm/systemd-escape)

    As udevadm, systemd-escape and the various service files are hard requirement,
    list it as explicitly so in the debian control file.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    ea3c64e View commit details
    Browse the repository at this point in the history
  6. Drop grep from udevadm

    According to the udevadm manual page --export produces a parseable list.
    
      -x, --export
          Print output as key/value pairs. Values are enclosed in single quotes.
    
    So using grep to drop lines that are not key/value pairs is just a
    resource waste without doing anything.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    d485c2f View commit details
    Browse the repository at this point in the history
  7. Put blkid in a variable

    By putting blkid in a variable we only have one place to have the whole
    string, could easily replace it with BLKID="$(command -v blkid)" or
    otherwise.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    0aa917f View commit details
    Browse the repository at this point in the history
  8. Depend on util-linux (for blkid)

    The busybox variant of blkid does not work by default with usbmount. So
    ensure we depend on the real thing.
    
    Things not supported:
    -p gets ignored and 'USAGE' is not returned.
    -o value is not supported
    -s FIELD is ignored
    
    It basically just dumps the known info and that's that.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    728c0c0 View commit details
    Browse the repository at this point in the history
  9. Put the usbmount directories in variables

    As with blkid, having the standard usbmount directories in variables
    makes use of these variables less error-prone on usage.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    ec8ba84 View commit details
    Browse the repository at this point in the history
  10. Quote and use curly bracers around variables

    Using quotes and curly braces around shell variables everywhere can be
    considered good programming practise andtends to be more consistent.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    0a8b311 View commit details
    Browse the repository at this point in the history
  11. Remove legacy .. backtick syntax

    It has a series of undefined behaviors related to quoting in POSIX.
    It imposes a custom escaping mode with surprising results.
    It's exceptionally hard to nest.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    cb70ddb View commit details
    Browse the repository at this point in the history
  12. Do not parse output of blkid

    The blkid tool can output exactly what we need using various parameters.
    
    This saves us some sed headaches. The only 'downside' is we can't use
    our own names for the variables, which affects 'FSTYPE' so that was
    renamed (rather then do a FSTYPE=$TYPE).
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    3f7548e View commit details
    Browse the repository at this point in the history
  13. Remove depracted egrep

    Using egrep is considered deprecated and should be avoided and not used.
    While we could use grep -q -E, using two simple string comparissions
    avoid having to call an external tool, making the script lighter and
    cleaner.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    26c2565 View commit details
    Browse the repository at this point in the history
  14. Replace depracted egrep with grep -E

    Use grep -E when quering fstab to avoid the deprecated egrep.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    a365b60 View commit details
    Browse the repository at this point in the history
  15. Use mountpoint instead of grep /proc/mounts

    Parsing /proc/mounts by hand is not needed as we have the 'mountpoint'
    utility (part of util-linux and busybox). This eases some regex foo
    which improves readbility.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    1fdd5da View commit details
    Browse the repository at this point in the history
  16. Ensure proper exit

    While not strictly needed it is considered good practise to ensure proper exit
    at the end of the script.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    3079c8e View commit details
    Browse the repository at this point in the history
  17. Add the -r parameter to read

    By default, read will interpret backslashes before spaces and line feeds,
    and otherwise strip them. This is rarely expected or desired.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    ba72fed View commit details
    Browse the repository at this point in the history
  18. Remove unused variables

    The read utility reads multiple variables with a dummy variable called
    'remainder'. Instead, use the more common and well recognized by checkers '_'
    (underscore) as a dummy variable.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    a41da1c View commit details
    Browse the repository at this point in the history
  19. Ensure grep is called with -E when using regex

    When passing regex to grep, make this explicit with the -E parameter.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    ffe4066 View commit details
    Browse the repository at this point in the history
  20. Add sourced file helper for shellcheck

    With usbmount now being shellcheck compliant, there is only one
    remaining warning, SC1091 about our sourced file.
    
    While we cannot scan whatever the user has installed, we can point
    shellcheck to the local default config instead.
    
    Note, that this will still produce a warning on shellcheck.net as it
    obviously still cannot access the file.
    
    Signed-off-by: Olliver Schinagl <[email protected]>
    oliv3r committed Oct 24, 2018
    Configuration menu
    Copy the full SHA
    a54a2ee View commit details
    Browse the repository at this point in the history