Opened 8 years ago

Closed 8 years ago

#26751 closed Cleanup/optimization (fixed)

Make dbshell exit with the shell's error code

Reported by: Étienne BERSAC Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: dbshell
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

For scripting, commands should return a non zero exit-code on error. But dbshell seems to ignore the exit code. Here is how to reproduce:

(venv) $ echo 'auieaui;' | django-admin dbshell
ERROR:  syntax error at or near "auieaui"
LINE 1: auieaui;
        ^
(venv) $ echo $?
0

I suggested a fix in https://github.com/django/django/pull/6768 . @charettes asked me to open a ticket for discussion. Here your are :)

Regards,
Étienne

Change History (5)

comment:1 by Tim Graham, 8 years ago

Description: modified (diff)
Has patch: set
Patch needs improvement: set
Summary: dbshell error handlingMake dbshell exit with the shell's error code
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Is a similar fix applicable for the other database backends? Not sure if tests are feasible.

comment:2 by Étienne BERSAC, 8 years ago

@timgraham, thanks for triaging :)

I applied the fix to other backends. That's actually not a problem of backends but how runshell manage subprocess.

comment:3 by Étienne BERSAC, 8 years ago

You're rigth, it's quite hard to test execvp because by definition, this function never returns.

comment:4 by Tim Graham, 8 years ago

Patch needs improvement: unset

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 03f6d27:

Fixed #26751 -- Made dbshell exit with the shell's error code.

Note: See TracTickets for help on using tickets.
Back to Top