1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix 'print -s -f'

This fix is backported from the Vashisht/Rader ksh2020 branch.

src/cmd/ksh93/bltins/print.c:
- Fix syncing history when print -s -f is used. For example, the
  following now correctly adds a 'cd' command to the history:
	print -s -f 'cd -- %q\n' "$PWD"
  Ref.:	https://github.com/att/ast/issues/425
	https://github.com/att/ast/pull/442

src/cmd/ksh93/include/version.h:
- Version date bump.

(cherry picked from commit 46ba7ecdc5c14cd73f6cb24b16c50bdc331a000e)
This commit is contained in:
Martijn Dekker 2020-05-14 11:36:16 +01:00
parent e856094ca2
commit 846ad93272
3 changed files with 16 additions and 2 deletions

View file

@ -329,7 +329,13 @@ skip2:
} while(*pdata.nextarg && pdata.nextarg!=argv);
if(pdata.nextarg == nullarg && pdata.argsize>0)
sfwrite(outfile,stakptr(staktell()),pdata.argsize);
if(sffileno(outfile)!=sffileno(sfstderr))
/*
* -f flag skips adding newline at the end of output, which causes issues
* with syncing history if -s and -f are used together. So don't sync now
* if sflag was given. History is synced later with hist_flush() function.
* https://github.com/att/ast/issues/425
*/
if(!sflag && sffileno(outfile)!=sffileno(sfstderr))
sfsync(outfile);
sfpool(sfstderr,pool,SF_WRITE);
exitval = pdata.err;