2014-11-08 14:55:09 +00:00
|
|
|
#!/bin/bash
|
2014-11-08 23:31:44 +00:00
|
|
|
# Convert a MSYS path list to Windows-native format.
|
2013-11-20 01:48:50 +00:00
|
|
|
# Status is zero if successful, nonzero otherwise.
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
# Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
# Take only the basename from the full pathname
|
|
|
|
me=${0//*\//}
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
usage="usage: ${me} PATHLIST"
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
help="$usage
|
|
|
|
or: ${me} OPTION
|
|
|
|
|
2014-11-08 23:31:44 +00:00
|
|
|
Convert a MSYS path list to Windows-native format.
|
2014-11-08 14:55:09 +00:00
|
|
|
|
|
|
|
PATHLIST should be a colon-separated list of MSYS paths, which will be
|
|
|
|
written to the standard output after performing these transformations:
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
1. Discard empty paths.
|
2014-11-08 14:55:09 +00:00
|
|
|
2. Replace: '\' with '/', '//' with '/' and ':' with ';'.
|
2014-11-19 20:15:32 +00:00
|
|
|
3. Translate absolute paths to Windows-native format.
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
--help display this help and exit
|
|
|
|
|
|
|
|
Report bugs to <bug-gnu-emacs@gnu.org>."
|
|
|
|
|
|
|
|
for arg
|
|
|
|
do
|
|
|
|
case $arg in
|
|
|
|
--help | --hel | --he | --h)
|
|
|
|
exec echo "$help" ;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break ;;
|
|
|
|
-*)
|
|
|
|
echo "${me}: invalid option: $arg" >&2
|
|
|
|
exit 1 ;;
|
|
|
|
*)
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
[ $# -eq 1 ] || {
|
|
|
|
echo "${me}: $usage" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
w32pathlist=""
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
# Put each MSYS path in one positional parameter and iterate through
|
|
|
|
# them
|
|
|
|
IFS=:
|
|
|
|
set -- $1
|
2013-11-20 01:48:50 +00:00
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
for p
|
|
|
|
do
|
|
|
|
[ -z "$p" ] && continue
|
2013-11-20 01:48:50 +00:00
|
|
|
|
2014-11-19 20:15:32 +00:00
|
|
|
if [ "${p:0:1}" != "/" ]
|
2013-11-30 15:42:13 +00:00
|
|
|
then
|
|
|
|
w32p=$p
|
2014-11-08 14:55:09 +00:00
|
|
|
elif [ -d "$p" ]
|
2013-11-20 01:48:50 +00:00
|
|
|
then
|
2014-11-08 14:55:09 +00:00
|
|
|
w32p=$(cd "$p" && pwd -W)
|
2013-11-20 01:48:50 +00:00
|
|
|
else
|
2014-11-08 14:55:09 +00:00
|
|
|
# Make some cleanup in the path and look for its deepest
|
|
|
|
# existing directory
|
2013-11-20 01:48:50 +00:00
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
p=${p//\\//}
|
|
|
|
p=${p//\/\///}
|
|
|
|
p=${p%/}
|
2013-11-20 01:48:50 +00:00
|
|
|
|
2014-11-08 23:31:44 +00:00
|
|
|
p1=$p
|
2014-11-08 14:55:09 +00:00
|
|
|
while :
|
2013-11-20 01:48:50 +00:00
|
|
|
do
|
2014-11-08 23:31:44 +00:00
|
|
|
p1=${p1%/*}
|
|
|
|
[ -z "$p1" ] && p1="/" && break
|
|
|
|
[ -d "$p1" ] && break
|
2013-11-20 01:48:50 +00:00
|
|
|
done
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
# translate the existing part and append the rest
|
2014-11-08 23:31:44 +00:00
|
|
|
w32p=$(cd "${p1}" && pwd -W)
|
|
|
|
remainder=${p#$p1}
|
2015-11-02 10:48:47 +00:00
|
|
|
w32p=${w32p%/}/${remainder#/}
|
2013-11-20 01:48:50 +00:00
|
|
|
fi
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
w32pathlist="${w32pathlist};${w32p}"
|
2013-11-20 01:48:50 +00:00
|
|
|
|
|
|
|
done
|
|
|
|
|
2014-11-08 14:55:09 +00:00
|
|
|
echo "${w32pathlist:1}"
|