Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active August 29, 2015 13:57
Show Gist options
  • Save mjf/9364889 to your computer and use it in GitHub Desktop.
Save mjf/9364889 to your computer and use it in GitHub Desktop.
shortfacl - Reformat POSIX.1e ACL long form to short form
#! /bin/sed -f
# shortfacl - Reformat POSIX.1e ACL long form to short form
# Copyright (C) 2014 Matous J. Fialka
# Released under the terms of The MIT License
# Use as `getfacl /path/to/object | shortfacl`
# Remove comments
s/#.*$//
# Remove trailing whitespace
s/[ \t]\+$//
# Shorten keywords
s/^\(.\)[^:]\+:/\1:/
# Join lines and cleanup
s/.*/&,/
H
$ {
x
s/,\n/,/g
s/\n\(.*\)/\1/
s/\(.*\),/\1/
s/,\+/,/g
s/,$//
s/^,//
p
}
d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment