From ea3d04ea0a7283f641ef59390f64bf9b133291e6 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 29 Dec 2012 07:31:27 +0530 Subject: [PATCH] perms batch mode confuses; print something to help What happens is that running ssh git@host perms reponame appears to hang, since it is waiting for STDIN. I added a message to help, since we don't want users losing files accidentally! (The other alternative is to add a specific option for batch mode, but this is backward incompatible for people who have scripts that may be doing this). thanks to Caleb Cushing for catching this ---- The "make sure Ctrl-C gets caught" thing needs some explanation. Without it, a user could inadvertently lose his gl-perms file if he ran the command in batch mode. You'd think that the Ctrl-C would hit the for (<>) { line and bail, but it manages to reach the _print( $pf, @a ); line somehow. Even trapping SIG INT does not help. I suspect it is to do with how signals are propagated by ssh across a "no-pty" session, but am not sure. --- src/commands/mirror | 2 +- src/commands/perms | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands/mirror b/src/commands/mirror index d091979..d72f9ae 100755 --- a/src/commands/mirror +++ b/src/commands/mirror @@ -48,7 +48,7 @@ if ( $cmd eq 'push' ) { if (-f "gl-creator") { # try to propagate the wild repo, including creator name and gl-perms my $creator = `cat gl-creator`; chomp($creator); - trace(1, `cat gl-perms 2>/dev/null | ssh $host CREATOR=$creator perms -c \\'$repo\\'`); + trace(1, `cat gl-perms 2>/dev/null | ssh $host CREATOR=$creator perms -c \\'$repo\\' 2>/dev/null`); } my $errors = 0; diff --git a/src/commands/perms b/src/commands/perms index ffb4bd9..88244a9 100755 --- a/src/commands/perms +++ b/src/commands/perms @@ -84,12 +84,15 @@ sub setperms { if ( not @_ ) { # legacy mode; pipe data in + print STDERR "'batch' mode started, waiting for input (run with '-h' for details).\n"; + print STDERR "Please hit Ctrl-C if you did not intend to do this.\n"; @ARGV = (); my @a; for (<>) { _die "Invalid role '$1'; check the rc file" if /(\S+)/ and not $rc{ROLES}{$1}; push @a, $_; } + print STDERR "\n"; # make sure Ctrl-C gets caught _print( $pf, @a ); return; }