Всегда пожалуйста. Я только что заметил, что упустил одну подробность: создавая объект команды в Julia, нужно быть особенно осторожным со специальными символами (например, с * из вашего примера). Julia не вызывает оболочку, а выполняет команды напрямую. Поэтому *, вероятно, сработает не так, как вы ожидаете.
Например, допустим, вы пытаетесь выполнить
command = `fossil add fernuser/tiddlers/*`
run(command)
Сначала Julia жалуется на неэкранированный * (нужно написать \*), но даже после исправления нужного результата не будет, поскольку сопоставление * с именами файлов в каталоге — это “globbing”, который предоставляют Bash и другие оболочки. run этого не делает, см., например, обсуждение экранирования команд (https://discourse.julialang.org/t/quoting-in-shell-commands/6781) и связанные обсуждения, в том числе рекурсивного удаления каталогов (https://discourse.julialang.org/t/removing-directory-contents-recursively/128761).
Самый простой обходной путь, вероятно, состоит в явном выполнении команды через оболочку, например с помощью bash -c '...'
command = `bash -c 'fossil add fernuser/tiddlers/*'`
run(command)
Тогда вы получите ожидаемое поведение используемой оболочки (если это Bash). Правда, Bash должен быть установлен в системе, но при необходимости это легко адаптировать.
Переведено с английского·Показать оригиналYou're most welcome. I have just noticed that I left out a detail: you may need to take particular care when constructing a command object in Julia if it includes special characters (such as the * appearing in your example). Rather than invoking a shell, Julia executes the commands itself. Consequently * likely won't behave as you expect.
For example, suppose you try to execute
command = `fossil add fernuser/tiddlers/*`
run(command)
Julia objects first to the bare * (you'd have to spell it \*), but fixing that still doesn't give the desired result because matching * against the directory's filenames is “globbing”, provided by Bash and similar shells. run doesn't perform that step, see for instance a discussion of quoting commands (https://discourse.julialang.org/t/quoting-in-shell-commands/6781) together with associated discussions such as recursive directory removal (https://discourse.julialang.org/t/removing-directory-contents-recursively/128761).
The most straightforward way of handling this is probably to explicitly execute that command through a shell, for instance using bash -c '...'
command = `bash -c 'fossil add fernuser/tiddlers/*'`
run(command)
You should then get the expected behavior of that shell (assuming Bash). This does require Bash to exist on the machine, but adapting it if necessary is straightforward.