reitzig / scripts

Collection of arguably useful shell scripts.
GNU General Public License v3.0
20 stars 10 forks source link

tlwhich don't work as intended on macOS #3

Closed quark67 closed 1 year ago

quark67 commented 1 year ago

Perhaps I misuses tlwich, but after creating a file named tlwhich.sh with the code, I enter in the terminal: tlwhich.sh todo (being in the directory where tlwich.sh is installed).

(by the way, I'm a complete beginner and I'm surprised I don't have to make the file executable... I'm on macOS, so on a UNIX-based OS).

The output of the command:

line 49: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
line 55: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
Files that define command todo:
    coop-writing.sty
    easy-todo.sty
    lilyglyphsStyle.sty
    luatodonotes.sty
    revquantum.sty
    todo.sty
    todonotes.sty
    udesoftec.cls
    uhhassignment.cls

Files that define command todo:
    coop-writing.sty
    easy-todo.sty
    lilyglyphsStyle.sty
    luatodonotes.sty
    revquantum.sty
    todo.sty
    todonotes.sty
    udesoftec.cls
    uhhassignment.cls

Files that define command todo:
    coop-writing.sty
    easy-todo.sty
    lilyglyphsStyle.sty
    luatodonotes.sty
    revquantum.sty
    todo.sty
    todonotes.sty
    udesoftec.cls
    uhhassignment.cls

Files that define command todo:
    coop-writing.sty
    easy-todo.sty
    lilyglyphsStyle.sty
    luatodonotes.sty
    revquantum.sty
    todo.sty
    todonotes.sty
    udesoftec.cls
    uhhassignment.cls

Get full paths by running 'kpsewhich <file>'

4 times "Files that define command todo:" with the same answers.

According to https://tex.stackexchange.com/a/184364/132405, I'm supposed to obtain (perhaps with more answers, since your exemple dates from 2017):

Files that define command todo:
    easy-todo.sty
    lilyglyphsStyle.sty
    todonotes.sty
    todo.sty
    tudscrdoc.cls
    udesoftec.cls

Files that define environment todo:
    ed.sty

Files that provide a package with similar name:
    easy-todo.sty
    fixmetodonotes.sty
    todonotes.sty
    todo.sty

According to https://www.geeksforgeeks.org/declare-command-in-linux-with-examples/, declare don't have a -A option. So, what must I do? I don't know from where "declare" is. The command declare --help don't work in the Terminal (declare --help is on the 4th screenshot on https://www.geeksforgeeks.org/declare-command-in-linux-with-examples/).

If needed, I have homebrew for installing newer version of (I don't know what).

reitzig commented 1 year ago

I'm surprised I don't have to make the file executable

+1

line 49: declare: -A: invalid option

This is the key. Since you're on Mac, I assume you have an ages-old BSD bash? For comparision:

$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)

Not the most recent one, but well.

Point is, the script is written for GNU tooling; the ones shipped with MacOS have all kinds of incompatibilities. You'll either have to adapt the script (find out how to declare arrays in your shell), rewrite in a real scripting language (which is what I would do today), or install GNU tools to make that exact script run. That's coreutils on homebrew, if memory serves.

Closing since I can't reproduce.


FWIW, the exact output of the command depends on your local TeXlive installation, and will most likely be different today from what I posted in 2017. Here is what I get with my TeXlive 2021 (oh boy, do I need to upgrade!)

— ~ $ tlwhich todo
Files that define command todo:
    easy-todo.sty
    lilyglyphsStyle.sty
    luatodonotes.sty
    revquantum.sty
    todonotes.sty
    todo.sty
    udesoftec.cls
    uhhassignment.cls

Files that define environment todo:
    ed.sty

Files that provide a package with similar name:
    easy-todo.sty
    fixmetodonotes.sty
    luatodonotes.sty
    snaptodo.sty
    todonotes.sty
    todo.sty
quark67 commented 1 year ago

No problem for closing this issue. If I run bash --version, I obtain GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin22) Copyright (C) 2007 Free Software Foundation, Inc. (for an OS updated on 2022). But yet, the current shell is zsh (zsh 5.8.1 (x86_64-apple-darwin22.0)).

Perhaps you could add on https://github.com/reitzig/scripts/blob/master/README.md the minimum requirements for your scripts (minimal version of bash, but it's perhaps too much work for a little audience to find the minimal version for all scripts). Do you suggest a modify the title of this issue so other Mac users can find it?

reitzig commented 1 year ago

but it's perhaps too much work for a little audience to find the minimal version for all scripts

Yeah, sorry. The requirements are "works on my machine when and for what I need it", literally. I'm sharing the scripts without any illusions about general utility; that's what my other repos are for. ;)

I have no way to estimate these things, but if there was considerable interest in tlwhich (or any other of my half-baked scripts), it would be possible to create separate projects for, with tests and dependency management and all that.

Do you suggest a modify the title of this issue so other Mac users can find it?

I imagine that would be helpful, yes. Thank you!