Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintanance improvement #36

Open
DevManu-de opened this issue Jan 4, 2021 · 0 comments
Open

Maintanance improvement #36

DevManu-de opened this issue Jan 4, 2021 · 0 comments

Comments

@DevManu-de
Copy link
Contributor

DevManu-de commented Jan 4, 2021

While working on the psh flags I think that it makes sense to combine

        expanded_ps1 = ps_expander(state, psh_vf_getstr(state, "PS1"));
        stat = read_cmdline(state, expanded_ps1, &buffer);
        xfree(expanded_ps1);
        if (stat == 1)
        {
            puts("");
            exit_psh(state, psh_vf_getint(state, "?"));
        }
        if (stat < 0)
            continue;
        cmd = new_command();
        stat = filpinfo(state, expand_alias(state, buffer), cmd);
        xfree(buffer);
        if (stat < 0)
        {
            free_command(cmd);
            continue;
        }
        psh_backend_do_run(state, cmd);
        free_command(cmd);

to a function. This would remove the douplicate code between main.c and args.c -c flag and therefore be easier to maintain and make implementing new features faster.
I thought of a function like print_exec_command(psh_state *state, char *buffer) that prints the output to stdout
and / or a function like get_exec_command(psh_state *state, char *buffer) that returns the output.
Before making any greater changes I wanted to hear your opinion on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant