Is the installer script actually present beside the binary? (#1632) * * `update` hands off to install.sh / install.ps1 and prints the command to run. * It derived that path from the binary's own location, which is not the same * question: the installer is placed beside the binary by install.sh, but a * binary moved, packaged, or built from source has no installer next to it, and * we still p
| 13662 | * Windows. A symlink counts: it is reported rather than followed, and the shell |
| 13663 | * will run it perfectly well. */ |
| 13664 | bool cbm_cli_installer_beside_binary(const char *dir) { |
| 13665 | if (!dir || !dir[0]) { |
| 13666 | return false; |
| 13667 | } |
| 13668 | char script[CLI_BUF_1K]; |
| 13669 | #ifdef _WIN32 |
| 13670 | const char *name = "install.ps1"; |
| 13671 | #else |
| 13672 | const char *name = "install.sh"; |
| 13673 | #endif |
| 13674 | int written = snprintf(script, sizeof(script), "%s/%s", dir, name); |
| 13675 | if (written <= 0 || (size_t)written >= sizeof(script)) { |
| 13676 | return false; |
| 13677 | } |
| 13678 | cbm_path_info_t info; |
| 13679 | return cbm_path_info_utf8(script, &info) == 0 && !info.is_directory; |
| 13680 | } |
| 13681 | |
| 13682 | int cbm_cmd_update(int argc, char **argv) { |
| 13683 | parse_auto_answer(argc, argv); |
no test coverage detected