Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cp shouldn't change atime of source file #1074

@nfischer

Description

@nfischer

Node version (or tell us if you're using electron or some other framework):

v10.19.0

ShellJS version (the most recent version/Github branch you see the bug on):

tip-of-tree master branch

Operating system:

Ubuntu 20.04

Description of the bug:

It looks like cp('sourceFile', 'destFile') updates the atime (access time) attribute of the source file. Unix cp doesn't seem to update the atime.

I noticed this while working on #869.

Example ShellJS command to reproduce the error:

shell.touch({ '-d': new Date(newModifyTimeMs), '-m': true }, srcFile);
shell.cp(srcFile, `${t.context.tmp}/dest`);
const stat = common.statFollowLinks(srcFile);

t.is(stat.mtime.getTime(), newModifyTimeMs); // mtime seems OK
t.is(stat.atime.getTime(), newAccessTimeMs); // this one fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    bash compatCompatibility issues with bash or POSIX behaviorfixBug/defect, or a fix for such a problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions