Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read -r -d should not ignore -r #17

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh

Any uppercase BUG_* names are modernish shell bug IDs.

2020-06-16:

- Passing the '-d' flag to the read builtin will no longer cause the '-r'
flag to be discarded when 'read -r -d' is run.

2020-06-15:

- The 'source' alias has been converted into a regular built-in command.
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/ksh93/bltins/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ int b_read(int argc,char *argv[], Shbltin_t *context)
if(opt_info.arg && *opt_info.arg!='\n')
{
char *cp = opt_info.arg;
flags &= ~((1<<D_FLAG)-1);
flags |= (mbchar(cp)<< D_FLAG);
flags &= ((1<<D_FLAG+1)-1);
flags |= (mbchar(cp)<<D_FLAG+1) | (1<<D_FLAG);
}
break;
case 'p':
Expand Down Expand Up @@ -283,7 +283,7 @@ int sh_readline(register Shell_t *shp,char **names, volatile int fd, int flags,s
tty_raw(fd,1);
if(!(flags&(N_FLAG|NN_FLAG)))
{
delim = ((unsigned)flags)>>D_FLAG;
delim = ((unsigned)flags)>>(D_FLAG+1);
ep->e_nttyparm.c_cc[VEOL] = delim;
ep->e_nttyparm.c_lflag |= ISIG;
tty_set(fd,TCSADRAIN,&ep->e_nttyparm);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#define SH_RELEASE "93u+m 2020-06-15"
#define SH_RELEASE "93u+m 2020-06-16"
5 changes: 5 additions & 0 deletions src/cmd/ksh93/tests/builtins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,10 @@ EOF
PATH=/dev/null
whence -q export) || err_exit '`builtin -d` deletes special builtins'

# ======
# `read -r -d` should not ignore `-r`
printf '\\\000' | read -r -d ''
[[ $REPLY == $'\\' ]] || err_exit "read -r -d '' ignores -r"

# ======
exit $((Errors<125?Errors:125))