Created
May 7, 2019 16:39
-
-
Save mk-pmb/6e64ae834b0e878656dbf06c94ee533c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# -*- coding: utf-8, tab-width: 2 -*- | |
function adjust_mod_dirnames () { | |
local MANIF= MOD_DIR= EXPECTED= | |
local -A MOD_INFO=() | |
for MANIF in */info.json; do | |
MOD_DIR="${MANIF%/*}" | |
eval MOD_INFO=( $(<"$MANIF" tr -s '{},' '\n' | sed -nre ' | |
s~^\s*"([a-z0-9_]+)":\s*"([ !#-Z_-z]*)"\s*$~[\1]=\x27\2\x27~p') ) | |
EXPECTED="${MOD_INFO[name]}_${MOD_INFO[version]}" | |
if [ "$MOD_DIR" == "$EXPECTED" ]; then | |
echo "# ok: '$MOD_DIR'" | |
else | |
echo "mv -nT -- '$MOD_DIR' '$EXPECTED'" | |
fi | |
done | |
} | |
adjust_mod_dirnames "$@"; exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment