这是indexloc提供的服务,不要输入任何密码
Skip to content

2nd run exits immediately #3

@macie

Description

@macie

When I run termrec second time, new shell exits immediately and it is impossible to record any commands:

$ SHELL='/bin/sh' ./termrec rec test.log
CWD: /home/macie/termrec
$ echo 123
123
$ ^D
Session Recorded Successfully!
$ cat test.log
{
	"duration": 5.55092907,
                                          	"version": 1,
	"timestamp": 1687726492,
	"width": 80,
	"height": 30,
	"command": "",
	"title": "",
	"env": {"SHELL":"/bin/sh","TERM":"xterm-256color","PS1":"$(__update_ps1)","PS2":" > "},
	"stdout": [
		[ 0, "" ],
		[ 0.0000, "$ " ],
		[ 2.0180, "e" ],
		[ 0.1563, "c" ],
		[ 0.1489, "h" ],
		[ 0.1277, "o" ],
		[ 0.1662, " " ],
		[ 0.3606, "1" ],
		[ 0.1419, "2" ],
		[ 0.2694, "3" ],
		[ 0.4154, "\u000d\u000d\u000a" ],
		[ 0.0002, "123\u000d\u000a" ],
		[ 0.0396, "$ " ],
		[ 1.7066, "^D\u000d\u000d\u000a" ]
	]
}
$ SHELL='/bin/sh' ./termrec rec test.log
CWD: /home/macie/termrec
Session Recorded Successfully!
$ cat test.log
{
	"duration": 0,
                                                   	"version": 1,
	"timestamp": 1687726530,
	"width": 80,
	"height": 30,
	"command": "",
	"title": "",
	"env": {"SHELL":"/bin/sh","TERM":"xterm-256color","PS1":"$(__update_ps1)","PS2":" > "},
	"stdout": [
		[ 0, "" ]
	]
}

If the program can read commands to be recorded, then it will be easy to automate regression testing during CI job (and local development). Example of simple end-user test where commands are read from stdin, line-by-line:

$ ./termrec rec test_rec.cast <<EOF
echo "test_string"
exit
EOF
$ grep -q "test_string" test_rec.cast

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions