--- loncom/debugging_tools/modify_config_files.pl 2024/07/09 14:18:16 1.26 +++ loncom/debugging_tools/modify_config_files.pl 2024/07/15 15:48:52 1.27 @@ -2,7 +2,7 @@ # # The LearningOnline Network # -# $Id: modify_config_files.pl,v 1.26 2024/07/09 14:18:16 raeburn Exp $ +# $Id: modify_config_files.pl,v 1.27 2024/07/15 15:48:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -388,7 +388,15 @@ if ($needs_inputrc_check) { if (!-e $bash_www_cnf) { system("touch $bash_www_cnf"); if (open(my $fh,'>',$bash_www_cnf)) { - print $fh "set enable-bracketed-paste off\n"; + print $fh <<'END'; +$if R + set enable-bracketed-paste off +$endif + +$if maxima + set enable-bracketed-paste off +$endif +END close($fh); } else { warn "**** Error: could not open $bash_www_cnf to add 'set enable-bracketed-paste to off'"; @@ -399,15 +407,42 @@ if ($needs_inputrc_check) { chown($wwwuid,$wwwgid,$bash_www_cnf); } } else { - my ($bracketed_paste_on,$bracketed_paste_off,@preserve); + my (%bracketed_paste_on,%bracketed_paste_off,@preserve,$condition); + $condition = ''; if (open(my $fh,'<',$bash_www_cnf)) { while (my $line=<$fh>) { chomp($line); + if ($line =~ /^\$if\s+(\w+)\s*$/) { + if ($1 eq 'R') { + $condition = 'r'; + } elsif ($1 eq 'maxima') { + $condition = 'maxima'; + } else { + $condition = 'other'; + } + } elsif ($line =~ /^\$endif\s*$/) { + $condition = ''; + } if ($line =~ /^\s*set\s+enable\-bracketed\-paste\s+(off|on)\s*$/) { if ($1 eq 'off') { - $bracketed_paste_off = 1; + if ($condition ne '') { + $bracketed_paste_off{$condition} = 1; + } else { + $bracketed_paste_off{all} = 1; + } + push(@preserve,$line); } else { - $bracketed_paste_on = 1; + if ($condition ne '') { + $bracketed_paste_on{$condition} = 1; + if (($condition eq 'r') || ($condition eq 'maxima')) { + push(@preserve,' set enable-bracketed-paste off'); + } else { + push(@preserve,$line); + } + } else { + $bracketed_paste_on{all} = 1; + push(@preserve,$line); + } } } else { push(@preserve,$line); @@ -415,13 +450,38 @@ if ($needs_inputrc_check) { } close($fh); } - if ($bracketed_paste_on || !$bracketed_paste_off) { + if (($bracketed_paste_on{r} || $bracketed_paste_on{maxima}) || + (!exists($bracketed_paste_off{r}) && !exists($bracketed_paste_on{r}) && + !exists($bracketed_paste_off{maxima}) && !exists($bracketed_paste_on{maxima}))) { if (open(my $fh,'>',$bash_www_cnf)) { - print $fh "set enable-bracketed-paste off\n"; if (@preserve) { foreach my $entry (@preserve) { print $fh "$entry\n"; } + if (!exists($bracketed_paste_off{r}) && !exists($bracketed_paste_on{r})) { +print $fh <<'END'; +$if R + set enable-bracketed-paste off +$endif +END + } + if (!exists($bracketed_paste_off{r}) && !exists($bracketed_paste_on{r})) { +print $fh <<'END'; +$if maxima + set enable-bracketed-paste off +$endif +END + } + } else { +print $fh <<'END'; +$if R + set enable-bracketed-paste off +$endif + +$if maxima + set enable-bracketed-paste off +$endif +END } close($fh); } else {