Skip to content

Commit 9b8242c

Browse files
committed
Print all log messages on stderr
That's a lot more straightforward to users, as other tools do the same. "Special messages" like the mount dir (on --appimage-mount) etc. are still printed to stdout for easier piping and being able to differentiate between log/error messages and values the users might want to use for automation. CC #923.
1 parent 9eb3d2e commit 9b8242c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/runtime.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void
215215
print_help(const char *appimage_path)
216216
{
217217
// TODO: "--appimage-list List content from embedded filesystem image\n"
218-
printf(
218+
fprintf(stderr,
219219
"AppImage options:\n\n"
220220
" --appimage-extract [<pattern>] Extract content from embedded filesystem image\n"
221221
" If pattern is passed, only extract matching files\n"
@@ -259,16 +259,16 @@ portable_option(const char *arg, const char *appimage_path, const char *name)
259259

260260
ssize_t length = readlink(appimage_path, fullpath, sizeof(fullpath));
261261
if (length < 0) {
262-
printf("Error getting realpath for %s\n", appimage_path);
262+
fprintf(stderr, "Error getting realpath for %s\n", appimage_path);
263263
exit(EXIT_FAILURE);
264264
}
265265
fullpath[length] = '\0';
266266

267267
sprintf(portable_dir, "%s.%s", fullpath, name);
268268
if (!mkdir(portable_dir, S_IRWXU))
269-
printf("Portable %s directory created at %s\n", name, portable_dir);
269+
fprintf(stderr, "Portable %s directory created at %s\n", name, portable_dir);
270270
else
271-
printf("Error creating portable %s directory at %s: %s\n", name, portable_dir, strerror(errno));
271+
fprintf(stderr, "Error creating portable %s directory at %s: %s\n", name, portable_dir, strerror(errno));
272272

273273
exit(0);
274274
}
@@ -563,7 +563,7 @@ int main(int argc, char *argv[]) {
563563

564564
// error check
565565
if (fs_offset < 0) {
566-
printf("Failed to get fs offset for %s\n", appimage_path);
566+
fprintf(stderr, "Failed to get fs offset for %s\n", appimage_path);
567567
exit(EXIT_EXECERROR);
568568
}
569569

@@ -575,7 +575,7 @@ int main(int argc, char *argv[]) {
575575

576576
ssize_t length = readlink(appimage_path, fullpath, sizeof(fullpath));
577577
if (length < 0) {
578-
printf("Error getting realpath for %s\n", appimage_path);
578+
fprintf(stderr, "Error getting realpath for %s\n", appimage_path);
579579
exit(EXIT_EXECERROR);
580580
}
581581
fullpath[length] = '\0';
@@ -737,8 +737,8 @@ int main(int argc, char *argv[]) {
737737
unsigned long offset = 0;
738738
unsigned long length = 0;
739739
appimage_get_elf_section_offset_and_length(appimage_path, ".upd_info", &offset, &length);
740-
// printf("offset: %lu\n", offset);
741-
// printf("length: %lu\n", length);
740+
// fprintf(stderr, "offset: %lu\n", offset);
741+
// fprintf(stderr, "length: %lu\n", length);
742742
// print_hex(appimage_path, offset, length);
743743
appimage_print_binary(appimage_path, offset, length);
744744
exit(0);
@@ -748,8 +748,8 @@ int main(int argc, char *argv[]) {
748748
unsigned long offset = 0;
749749
unsigned long length = 0;
750750
appimage_get_elf_section_offset_and_length(appimage_path, ".sha256_sig", &offset, &length);
751-
// printf("offset: %lu\n", offset);
752-
// printf("length: %lu\n", length);
751+
// fprintf(stderr, "offset: %lu\n", offset);
752+
// fprintf(stderr, "length: %lu\n", length);
753753
// print_hex(appimage_path, offset, length);
754754
appimage_print_binary(appimage_path, offset, length);
755755
exit(0);
@@ -889,15 +889,15 @@ int main(int argc, char *argv[]) {
889889
strcpy (portable_home_dir, fullpath);
890890
strcat (portable_home_dir, ".home");
891891
if(is_writable_directory(portable_home_dir)){
892-
printf("Setting $HOME to %s\n", portable_home_dir);
892+
fprintf(stderr, "Setting $HOME to %s\n", portable_home_dir);
893893
setenv("HOME",portable_home_dir,1);
894894
}
895895

896896
/* If there is a directory with the same name as the AppImage plus ".config", then export $XDG_CONFIG_HOME */
897897
strcpy (portable_config_dir, fullpath);
898898
strcat (portable_config_dir, ".config");
899899
if(is_writable_directory(portable_config_dir)){
900-
printf("Setting $XDG_CONFIG_HOME to %s\n", portable_config_dir);
900+
fprintf(stderr, "Setting $XDG_CONFIG_HOME to %s\n", portable_config_dir);
901901
setenv("XDG_CONFIG_HOME",portable_config_dir,1);
902902
}
903903

0 commit comments

Comments
 (0)