Skip to content

Commit

Permalink
gui: make the bootstrap script clean up after itself
Browse files Browse the repository at this point in the history
  • Loading branch information
sahib committed May 11, 2016
1 parent 3614090 commit 811260f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/cmdline.c
Expand Up @@ -130,18 +130,25 @@ static void rm_cmd_show_manpage(void) {
static const char RM_PY_BOOTSTRAP[] = ""
"# This is a bootstrap script for the rmlint-gui. \n"
"# See the src/rmlint.c in rmlint's source for more info. \n"
"import sys \n"
"import sys, os \n"
" \n"
"# Also default to dist-packages on debian(-based): \n"
"paths = [p for p in sys.path if 'site-package' in p] \n"
"sys.path.extend([d.replace('site-packages', 'dist-packages') for d in paths]) \n"
" \n"
"# Cleanup self: \n"
"try: \n"
" os.remove(sys.argv[0]) \n"
"except: \n"
" print('Note: Could not remove bootstrap script at ', sys.argv[0]) \n"
" \n"
"# Run shredder by importing the main: \n"
"try: \n"
" import shredder \n"
" shredder.run_gui() \n"
"except ImportError as err: \n"
" print('oh', err) \n"
" print('Failed to load shredder:', err) \n"
" print('This might be due to a corrupted install; try reinstalling.') \n"
;


Expand All @@ -167,6 +174,8 @@ static void rm_cmd_start_gui(int argc, const char **argv) {
return;
}

close(bootstrap_fd);

while(*command) {
const char *all_argv[512];
const char **argp = &all_argv[0];
Expand Down Expand Up @@ -194,15 +203,6 @@ static void rm_cmd_start_gui(int argc, const char **argv) {
/* Try next command... */
command++;
}

close(bootstrap_fd);

if(g_remove(bootstrap_path) < 0) {
rm_log_warning_line(
"Could not delete bootstrap script: %s",
g_strerror(errno)
);
}
}

static int rm_cmd_maybe_switch_to_gui(int argc, const char **argv) {
Expand Down

0 comments on commit 811260f

Please sign in to comment.