Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ static int config_parse_file(char ***argv, char **workdir)
jsmntok_t *tokens;
struct stat stat;
char *data;
char *config_file;
char **config_argv;
char **entrypoint;
int parsed_env, parsed_workdir, parsed_args, parsed_entrypoint;
Expand All @@ -582,7 +583,12 @@ static int config_parse_file(char ***argv, char **workdir)
int fd;
int i;

fd = open(CONFIG_FILE_PATH, O_RDONLY);
config_file = getenv("KRUN_CONFIG");
if (!config_file) {
config_file = CONFIG_FILE_PATH;
}

Copy link
Contributor

@alyssarosenzweig alyssarosenzweig Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit cleaner, maybe:

	config_file = getenv("KRUN_CONFIG");
	if (!config_file) {
                config_file = CONFIG_FILE_PATH;
        }
	fd = open(config_file, O_RDONLY);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if you don't care about MSVC, open(getenv("KRUN_CONFIG") ?: CONFIG_FILE_PATH, O_RDONLY) is a one-liner with the elvis operator 🕺

fd = open(config_file, O_RDONLY);
if (fd < 0) {
return ret;
}
Expand Down