diff --git a/src/pextlib1.0/readline.c b/src/pextlib1.0/readline.c
index e955f8e7..c2049c25 100644
a
|
b
|
int ReadlineCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_ |
267 | 267 | add line |
268 | 268 | read filename |
269 | 269 | write filename |
| 270 | append filename |
270 | 271 | stifle max |
271 | 272 | unstifle |
272 | 273 | */ |
… |
… |
int RLHistoryCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl |
277 | 278 | char* s = NULL; |
278 | 279 | int i = 0; |
279 | 280 | Tcl_Obj *tcl_result; |
| 281 | FILE *hist_file; |
280 | 282 | #endif |
281 | 283 | |
282 | 284 | if (objc < 2) { |
… |
… |
int RLHistoryCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl |
309 | 311 | } |
310 | 312 | s = Tcl_GetString(objv[2]); |
311 | 313 | write_history(s); |
| 314 | } else if (0 == strcmp("append", action)) { |
| 315 | if (objc != 3) { |
| 316 | Tcl_WrongNumArgs(interp, 1, objv, "append filename"); |
| 317 | return TCL_ERROR; |
| 318 | } |
| 319 | s = Tcl_GetString(objv[2]); |
| 320 | |
| 321 | hist_file = fopen(s, "a"); |
| 322 | fprintf(hist_file, "%s\n", current_history()->line); |
| 323 | fclose(hist_file); |
312 | 324 | } else if (0 == strcmp("stifle", action)) { |
313 | 325 | if (objc != 3) { |
314 | 326 | Tcl_WrongNumArgs(interp, 1, objv, "stifle maxlines"); |
diff --git a/src/port/port.tcl b/src/port/port.tcl
index 73a3a7e9..5d1b52b3 100755
a
|
b
|
proc attempt_completion { text word start end } { |
4802 | 4802 | } |
4803 | 4803 | |
4804 | 4804 | |
4805 | | proc get_next_cmdline { in out use_readline prompt linename } { |
| 4805 | proc get_next_cmdline { in out use_readline prompt linename history_file } { |
4806 | 4806 | upvar $linename line |
4807 | 4807 | |
4808 | 4808 | set line "" |
… |
… |
proc get_next_cmdline { in out use_readline prompt linename } { |
4828 | 4828 | set line [string trim $line] |
4829 | 4829 | |
4830 | 4830 | if { $use_readline && $line ne "" } { |
| 4831 | # Create macports user directory if it does not exist yet |
| 4832 | if {![file isdirectory $macports::macports_user_dir]} { |
| 4833 | file mkdir $macports::macports_user_dir |
| 4834 | |
| 4835 | # Also write the history file if this is the case (this sets |
| 4836 | # the cookie at the top of the file and perhaps other things) |
| 4837 | rl_history write $history_file |
| 4838 | } |
| 4839 | |
| 4840 | # Add history item to memory... |
4831 | 4841 | rl_history add $line |
| 4842 | # ... and then append that item to the history file |
| 4843 | rl_history append $history_file |
4832 | 4844 | } |
4833 | 4845 | } |
4834 | 4846 | |
… |
… |
proc process_command_file { in } { |
4870 | 4882 | } |
4871 | 4883 | |
4872 | 4884 | # Get a command line |
4873 | | if { [get_next_cmdline $in stdout $use_readline $prompt line] <= 0 } { |
| 4885 | if { [get_next_cmdline $in stdout $use_readline $prompt line $history_file] <= 0 } { |
4874 | 4886 | puts "" |
4875 | 4887 | break |
4876 | 4888 | } |
… |
… |
proc process_command_file { in } { |
4885 | 4897 | } |
4886 | 4898 | } |
4887 | 4899 | |
4888 | | # Create macports user directory if it does not exist yet |
4889 | | if {$use_readline && ![file isdirectory $macports::macports_user_dir]} { |
4890 | | file mkdir $macports::macports_user_dir |
4891 | | } |
4892 | | # Save readine history |
4893 | | if {$use_readline && [file isdirectory $macports::macports_user_dir]} { |
4894 | | rl_history write $history_file |
4895 | | } |
4896 | | |
4897 | 4900 | # Say goodbye |
4898 | 4901 | if { $noisy } { |
4899 | 4902 | puts "Goodbye" |