ssh2-scp 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,11 +143,13 @@ class SshFs {
143
143
  async readListings(remotePath, flags) {
144
144
  const operand = remotePath.startsWith("-") ? "./" + remotePath : remotePath;
145
145
  const path = "'" + operand.replace(/'/g, "'\\''") + "'";
146
- const listing = (flags2) => {
147
- const ls = `ls -${flags2}`;
148
- return `( ${ls} --full-time "$1" 2>/dev/null || ${ls}T "$1" 2>/dev/null || ${ls} "$1" )`;
149
- };
150
- const script = `export LC_ALL=C TZ=UTC0; ${listing(flags)} && printf "\\000" && ${listing(flags + "u")}`;
146
+ const script = [
147
+ 'if [ -n "$LC_ALL" ]; then export LC_CTYPE="$LC_ALL"; unset LC_ALL; fi',
148
+ "export LC_TIME=C TZ=UTC0",
149
+ 'if ls -d --full-time / >/dev/null 2>&1; then full=--full-time; elif [ "$(ls -dT / 2>/dev/null)" = / ]; then full=-T; else full=; fi',
150
+ // Only the probed option may expand to zero arguments. Always quote the path.
151
+ `ls -${flags} $full "$1" && printf "\\000" && ls -${flags}u $full "$1"`
152
+ ].join("; ");
151
153
  const output = await this.runCmd(`sh -c '${script}' sh ${path}`);
152
154
  const [modified, accessed = ""] = output.split("\0");
153
155
  return { entries: parseListing(modified), accessed: parseListing(accessed) };
@@ -141,11 +141,13 @@ class SshFs {
141
141
  async readListings(remotePath, flags) {
142
142
  const operand = remotePath.startsWith("-") ? "./" + remotePath : remotePath;
143
143
  const path = "'" + operand.replace(/'/g, "'\\''") + "'";
144
- const listing = (flags2) => {
145
- const ls = `ls -${flags2}`;
146
- return `( ${ls} --full-time "$1" 2>/dev/null || ${ls}T "$1" 2>/dev/null || ${ls} "$1" )`;
147
- };
148
- const script = `export LC_ALL=C TZ=UTC0; ${listing(flags)} && printf "\\000" && ${listing(flags + "u")}`;
144
+ const script = [
145
+ 'if [ -n "$LC_ALL" ]; then export LC_CTYPE="$LC_ALL"; unset LC_ALL; fi',
146
+ "export LC_TIME=C TZ=UTC0",
147
+ 'if ls -d --full-time / >/dev/null 2>&1; then full=--full-time; elif [ "$(ls -dT / 2>/dev/null)" = / ]; then full=-T; else full=; fi',
148
+ // Only the probed option may expand to zero arguments. Always quote the path.
149
+ `ls -${flags} $full "$1" && printf "\\000" && ls -${flags}u $full "$1"`
150
+ ].join("; ");
149
151
  const output = await this.runCmd(`sh -c '${script}' sh ${path}`);
150
152
  const [modified, accessed = ""] = output.split("\0");
151
153
  return { entries: parseListing(modified), accessed: parseListing(accessed) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-scp",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Remote file system operations over SSH2 session without SFTP",
5
5
  "scripts": {
6
6
  "build": "npm run build:esm && npm run build:cjs",