texindex.bat 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. @echo off
  2. REM Copyright 2016 Free Software Foundation, Inc.
  3. REM
  4. REM This program is free software; you can redistribute it and/or modify
  5. REM it under the terms of the GNU General Public License as published by
  6. REM the Free Software Foundation; either version 3 of the License,
  7. REM or (at your option) any later version.
  8. REM
  9. REM This program is distributed in the hope that it will be useful,
  10. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. REM GNU General Public License for more details.
  13. REM
  14. REM You should have received a copy of the GNU General Public License
  15. REM along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. REM
  17. REM Originally written by Eli Zaretskii.
  18. REM Please send bug reports, etc. to bug-texinfo@gnu.org.
  19. REM
  20. REM Batch file wrapper for the texindex.awk program.
  21. REM See the texindex shell script for more rationale.
  22. REM
  23. setlocal
  24. REM Directory where this script lives with a trailing backslash
  25. set mydir=%~dp0
  26. REM Allow the user override the awk interpreter location
  27. set awkbinary=
  28. if "%TEXINDEX_AWK%" == "" goto DefaultAwk
  29. set awkbinary=%TEXINDEX_AWK%
  30. if exist "%awkbinary%.exe" goto UserAwk
  31. if exist "%awkbinary%" goto UserAwk
  32. echo %0: TEXINDEX_AWK environment variable set, but its value
  33. echo %0: is not a readable file. Ignoring TEXINDEX_AWK.
  34. :DefaultAwk
  35. set awkbinary=gawk
  36. :UserAwk
  37. REM Find the texindex.awk script file
  38. set tiscript=
  39. if "%TEXINDEX_SCRIPT%" == "" goto DefaultScript
  40. set tiscript=%TEXINDEX_SCRIPT%
  41. if exist "%tiscript%" goto UserScript
  42. echo %0: TEXINDEX_SCRIPT environment variable set, but its value
  43. echo %0: is not a readable file. Ignoring TEXINDEX_SCRIPT.
  44. :DefaultScript
  45. REM In the development tree, the script is in ../texindex/
  46. set tiscript="%mydir%..\texindex\texindex.awk"
  47. if exist %tiscript% goto UserScript
  48. REM The installed script should be in the ../share/ directory relative to us
  49. set tiscript="%mydir%..\share\texindex.awk"
  50. REM If not found, abort
  51. if exist %tiscript% goto UserScript
  52. echo %0: could not locate texindex.awk script, quitting
  53. exit /b 1
  54. :UserScript
  55. REM Double each backslash in our name because Gawk will interpret
  56. REM backslashes in the name such that e.g. \t becomes a TAB
  57. set mypath=%0
  58. set escaped=%mypath:\=\\%
  59. REM Finally, invoke the script
  60. "%awkbinary%" -v Invocation_name="%escaped%" -f "%tiscript%" -- %*