Created
May 8, 2015 12:09
-
-
Save pochemuto/ffa0d509b0ccfc08a6dc to your computer and use it in GitHub Desktop.
iml-copy
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
#!/usr/bin/env bash | |
if [[ $# -ne 2 ]]; then | |
echo Копирование iml-файлов в другой каталок с заменой \$MODULE_DIR\$ на абсолютный путь | |
echo Usage: command iml-file target-dir | |
exit 1 | |
fi | |
get_abs_filename() { | |
# $1 : relative filename | |
if [ -d "$(dirname "$1")" ]; then | |
echo "$(cd "$(dirname "$1")" >> /dev/null && pwd)/$(basename "$1")" | |
fi | |
} | |
IML_FILE_PATH=`get_abs_filename "${1}"` | |
IML_FILE=`basename "$IML_FILE_PATH"` | |
TARGET_DIR="${2}" | |
OUTPUT="$TARGET_DIR/$IML_FILE" | |
BASE_PATH=`dirname "$IML_FILE_PATH"` | |
# escape slashes | |
BASE_PATH="${BASE_PATH//\//\\/}" | |
sed "s/\\\$MODULE_DIR\\\$/$BASE_PATH/g" "$IML_FILE_PATH" > "$OUTPUT" | |
echo Copied to $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment