brsh 1.3.0 → 2.0.0

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.
Files changed (59) hide show
  1. package/.github/workflows/busybox-compat.yml +166 -0
  2. package/.github/workflows/release.yml +40 -0
  3. package/.releaserc.json +18 -0
  4. package/CHANGELOG.md +355 -0
  5. package/bin/brsh-cmd.js +78 -0
  6. package/bin/exportFileSystem.js +81 -156
  7. package/busybox-testsuite/cat.tests +49 -0
  8. package/busybox-testsuite/cp.tests +206 -0
  9. package/busybox-testsuite/grep.tests +237 -0
  10. package/busybox-testsuite/testing.sh +180 -0
  11. package/dist/brsh.css +2 -0
  12. package/dist/shell.es.js +5667 -0
  13. package/dist/shell.es.js.map +1 -0
  14. package/dist/shell.min.js +14 -219
  15. package/dist/shell.min.js.map +1 -147
  16. package/dist/terminal.es.js +6228 -0
  17. package/dist/terminal.es.js.map +1 -0
  18. package/dist/terminal.min.js +113 -18
  19. package/dist/terminal.min.js.map +1 -21
  20. package/index.js +231 -56
  21. package/lib/Command.js +12 -1
  22. package/lib/Context.js +12 -4
  23. package/lib/FileSystem.js +99 -6
  24. package/lib/NodeFileSystem.js +238 -0
  25. package/lib/Result.js +6 -0
  26. package/lib/ScriptCommand.js +193 -15
  27. package/lib/Terminal.js +192 -11
  28. package/lib/WasmCommand.js +252 -0
  29. package/lib/buildFilesystemStructure.js +58 -0
  30. package/lib/builtins/cat.js +67 -9
  31. package/lib/builtins/echo.js +36 -5
  32. package/lib/builtins/false.js +13 -0
  33. package/lib/builtins/grep.js +267 -0
  34. package/lib/builtins/index.js +9 -2
  35. package/lib/builtins/ls.js +86 -18
  36. package/lib/builtins/test.js +105 -0
  37. package/lib/builtins/true.js +10 -0
  38. package/lib/local/chmod.js +72 -0
  39. package/lib/local/cp.js +156 -0
  40. package/lib/local/index.js +9 -1
  41. package/lib/local/jsfunction.js +58 -0
  42. package/lib/local/mkdir.js +44 -0
  43. package/lib/local/mv.js +96 -0
  44. package/lib/local/pwd.js +13 -0
  45. package/lib/local/read.js +107 -0
  46. package/lib/local/rm.js +71 -0
  47. package/lib/local/which.js +2 -2
  48. package/package.json +31 -34
  49. package/test/builtins.test.js +505 -0
  50. package/test/exportFileSystem.test.js +226 -0
  51. package/test/helpers.js +35 -0
  52. package/test/local-commands.test.js +593 -0
  53. package/test/node-filesystem.test.js +133 -0
  54. package/test/scripts.test.js +277 -0
  55. package/test/shell.test.js +245 -0
  56. package/test/streaming.test.js +113 -0
  57. package/vite.config.shell.js +21 -0
  58. package/vite.config.terminal.js +27 -0
  59. package/vitest.config.js +15 -0
@@ -1,47 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const esbuild = require('esbuild');
4
5
  const fs = require('fs');
5
6
  const path = require('path');
6
7
  const cla = require('command-line-args');
7
8
  const tmp = require('tmp');
8
-
9
- //build deps
10
- const webpack = require('webpack-stream');
11
- const wp = require('webpack');
12
- const through = require('through2');
13
- const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
14
-
15
- const ignore = ['.DS_Store'];
9
+ const { polyfillNode } = require('esbuild-plugin-polyfill-node');
10
+ const { buildStructure } = require('../lib/buildFilesystemStructure');
16
11
 
17
12
  let options;
18
13
  try {
19
14
  options = cla([
20
15
  {
21
- name: "root",
16
+ name: 'root',
22
17
  defaultOption: true,
23
18
  type: String,
24
19
  required: true
25
20
  },
26
21
  {
27
- name: "variable",
28
- alias: "v",
22
+ name: 'variable',
23
+ alias: 'v',
29
24
  required: true,
30
25
  type: String
31
26
  },
32
27
  {
33
- name: "output",
34
- alias: "o",
28
+ name: 'output',
29
+ alias: 'o',
35
30
  type: String
36
31
  },
37
32
  {
38
- name: "pretty",
39
- alias: "p",
33
+ name: 'pretty',
34
+ alias: 'p',
40
35
  type: Boolean
41
36
  },
42
37
  {
43
- name: "hyperlinks",
44
- alias: "h",
38
+ name: 'hyperlinks',
39
+ alias: 'h',
45
40
  type: Boolean
46
41
  }
47
42
  ]);
@@ -51,168 +46,98 @@ try {
51
46
  }
52
47
 
53
48
  if(!options.root) {
54
- console.log("missing required directory root");
49
+ console.log('missing required directory root');
50
+ process.exit(1);
51
+ }
52
+
53
+ if(!options.variable) {
54
+ console.log('missing required --variable (-v) flag');
55
55
  process.exit(1);
56
56
  }
57
57
 
58
58
  try {
59
59
  fs.accessSync(options.root, fs.constants.R_OK);
60
60
  } catch(e) {
61
- console.log("cant access specified root directory");
61
+ console.log('cant access specified root directory');
62
62
  process.exit(1);
63
63
  }
64
64
 
65
- const functions = [];
66
-
67
- function cleanFunction(code) {
68
- const trimmed = code.trim();
69
- if(trimmed.endsWith(';')) {
70
- return trimmed.substring(0, trimmed.length -1);
71
- }
72
- return trimmed;
73
- }
74
-
75
- function buildStructure(root) {
76
- try {
77
- const sub = fs.readdirSync(root);
78
- return sub.reduce((structure, handle) => {
79
- if(ignore.includes(handle)) {
80
- return structure;
81
- }
82
- try {
83
- //Check if this is a DIR
84
- const stat = fs.lstatSync(path.join(root, handle));
85
- if(stat.isDirectory()) {
86
- fs.readdirSync(path.join(root, handle));
87
- structure[handle] = buildStructure(path.join(root, handle));
88
-
89
- return structure
90
- }
91
-
92
- //Its a file lets prepare to import
93
- fs.readFileSync(path.join(root, handle), 'utf8');
94
-
95
- if(handle.endsWith('.js')) {
96
- //strip extensions form JS files
97
- structure[handle.substring(0, handle.length - 3)] = `require('${path.resolve(root, handle)}')`;
98
- return structure;
99
- }
100
- structure[handle] = `require('${path.resolve(root, handle)}')`;
101
- } catch(fe) {
102
- //ignore files we cant access for some reason
103
- }
104
- return structure;
105
- }, {});
106
- } catch(e) {
107
- console.log("cant access specified directory");
108
- process.exit(1);
109
- }
65
+ let struct;
66
+ try {
67
+ struct = buildStructure(options.root);
68
+ } catch(e) {
69
+ console.log('cant access specified directory');
70
+ process.exit(1);
110
71
  }
72
+ const { filesystem, permissions } = struct;
73
+ const fsJson = JSON.stringify(filesystem, null, options.pretty ? 2 : null);
74
+ const permJson = JSON.stringify(permissions, null, options.pretty ? 2 : null);
75
+ const fsJS = fsJson.replace(/"(require\('.*?'\))"/gm, '$1');
111
76
 
112
- const struct = buildStructure(options.root);
113
- let json = JSON.stringify(struct, null, options.pretty ? 2 : null);
114
-
115
- //convert JSON require strings to JS
116
- let JS = 'module.exports = ' + json.replace(/"(require\('.*?'\))"/gm, '$1');
77
+ let JS = `module.exports = { filesystem: ${fsJS}, permissions: ${permJson} }`;
117
78
 
118
- const tf = tmp.fileSync({
119
- postfix: '.tmp.js'
120
- });
121
-
122
- //create Temp File for JS
79
+ const tf = tmp.fileSync({ postfix: '.tmp.js' });
123
80
  fs.writeFileSync(tf.name, JS);
124
81
 
125
- const env = {
126
- NODE_ENV: 'production',
127
- COLORTERM: 'truecolor',
128
- TERM: 'color',
129
- };
130
-
131
82
  const alias = {
132
83
  'supports-color': 'supports-color/index',
133
84
  };
134
85
 
135
86
  if(options.hyperlinks) {
136
- env.FORCE_HYPERLINK = 'true'
137
- alias['supports-hyperlinks'] = 'supports-hyperlinks/index'
87
+ alias['supports-hyperlinks'] = 'supports-hyperlinks/index';
138
88
  }
139
89
 
140
- const w = webpack({
141
- mode: 'production',
142
- entry: {
143
- fs: tf.name,
144
- },
145
- output: {
146
- library: {
147
- name: options.variable,
148
- type: 'var',
149
- },
150
- filename: '[name].js'
151
- },
152
- module: {
153
- rules: [
154
- {
155
- test: /\.(?:gif|png|jpg|jpeg|bmp)$/i,
156
- type: 'asset/inline',
157
- },
158
- {
159
- test: function (modulePath) {
160
- const handledExtensions = ['gif', 'png', 'jpg', 'jpeg', 'bmp', 'js'];
161
-
162
- const handled = handledExtensions.reduce((acc, ext) => {
163
- if(acc) {
164
- return true;
165
- }
166
-
167
- if(modulePath.endsWith(ext)) {
168
- return true;
169
- }
170
-
171
- return false;
172
- }, false);
90
+ const textLoaderPlugin = {
91
+ name: 'textLoader',
92
+ setup(build) {
93
+ build.onLoad({ filter: /.*$/ }, async (args) => {
94
+ const filename = path.basename(args.path);
95
+ if (!filename.endsWith('.js')
96
+ && !filename.endsWith('.json')
97
+ && !filename.endsWith('.ts')
98
+ && !filename.endsWith('.gif')
99
+ && !filename.endsWith('.png')
100
+ && !filename.endsWith('.jpg')
101
+ && !filename.endsWith('.jpeg')
102
+ && !filename.endsWith('.bmp')
103
+ ) {
104
+ const contents = await fs.promises.readFile(args.path, 'utf8');
105
+ return { contents, loader: 'text' };
106
+ }
107
+ });
108
+ }
109
+ };
173
110
 
174
- return !handled;
175
- },
176
- type: 'asset/source'
177
- },
178
- ],
111
+ esbuild.build({
112
+ entryPoints: [tf.name],
113
+ bundle: true,
114
+ format: 'iife',
115
+ platform: 'browser',
116
+ treeShaking: true,
117
+ outfile: options.output,
118
+ allowOverwrite: true,
119
+ globalName: options.variable,
120
+ minify: true,
121
+ sourcemap: false,
122
+ loader: {
123
+ '.gif': 'binary',
124
+ '.png': 'binary',
125
+ '.jpg': 'binary',
126
+ '.jpeg': 'binary',
127
+ '.bmp': 'binary'
179
128
  },
180
129
  plugins: [
181
- new wp.DefinePlugin({
182
- __BUILD_ENV: JSON.stringify(env)
183
- }),
184
- new wp.ProvidePlugin({
185
- process: require.resolve('./shims/process-shim.js')
186
- }),
187
- new NodePolyfillPlugin({
188
- excludeAliases: ['console', 'tty', 'process']
189
- })
130
+ textLoaderPlugin,
131
+ polyfillNode()
190
132
  ],
191
- optimization: {
192
- minimize: !options.pretty,
133
+ define: {
134
+ 'process.env.NODE_ENV': JSON.stringify('production'),
135
+ 'process.env.COLORTERM': JSON.stringify('truecolor'),
136
+ 'process.env.TERM': JSON.stringify('color'),
137
+ 'process.env.FORCE_HYPERLINK': options.hyperlinks ? JSON.stringify('true') : JSON.stringify('false'),
193
138
  },
194
- resolve: {
195
- fallback: {
196
- fs: false,
197
- net: false,
198
- process: require.resolve('./shims/process-shim.js'),
199
- tty: require.resolve('./shims/tty-shim.js')
200
- },
201
- alias
202
- }
203
- }, wp);
204
-
205
- const filePipe = through.obj(function (file, enc, cb) {
206
- if (file.path.endsWith('.js')) {
207
- this.push(file.contents);
208
- }
209
-
210
- cb();
211
- });
212
-
213
- if(options.output) {
214
- const fileStream = fs.createWriteStream(options.output);
215
- w.pipe(filePipe).pipe(fileStream);
216
- } else {
217
- w.pipe(filePipe).pipe(process.stdout);
218
- }
139
+ alias,
140
+ })
141
+ .then(() => {
142
+ console.log('Build succeeded');
143
+ });
@@ -0,0 +1,49 @@
1
+ #!/bin/sh
2
+
3
+ # Copyright 2018 by Denys Vlasenko <vda.linux@googlemail.com>
4
+ # Licensed under GPLv2, see file LICENSE in this source tree.
5
+
6
+ . ./testing.sh
7
+
8
+ # testing "description" "command" "result" "infile" "stdin"
9
+ optional FEATURE_CATV
10
+ testing 'cat -e' \
11
+ 'cat -e' \
12
+ 'foo$\n' \
13
+ '' \
14
+ 'foo\n'
15
+ SKIP=
16
+
17
+ optional FEATURE_CATV
18
+ testing 'cat -v' \
19
+ 'cat -v' \
20
+ 'foo\n' \
21
+ '' \
22
+ 'foo\n'
23
+ SKIP=
24
+
25
+ optional FEATURE_CATN
26
+ testing 'cat -n' \
27
+ 'cat -n' \
28
+ "\
29
+ 1 line 1
30
+ 2
31
+ 3 line 3
32
+ " \
33
+ '' \
34
+ 'line 1\n\nline 3\n'
35
+ SKIP=
36
+
37
+ optional FEATURE_CATN
38
+ testing 'cat -b' \
39
+ 'cat -b' \
40
+ "\
41
+ 1 line 1
42
+
43
+ 2 line 3
44
+ " \
45
+ '' \
46
+ 'line 1\n\nline 3\n'
47
+ SKIP=
48
+
49
+ exit $FAILCOUNT
@@ -0,0 +1,206 @@
1
+ #!/bin/sh
2
+ # Copyright 2010 by Denys Vlasenko
3
+ # Licensed under GPLv2, see file LICENSE in this source tree.
4
+
5
+ . ./testing.sh
6
+
7
+ # Opening quote in "omitting directory 'dir'" message:
8
+ sq='`' # GNU cp: `
9
+ sq="'" # bbox cp: '
10
+
11
+ rm -rf cp.testdir >/dev/null
12
+
13
+ mkdir cp.testdir
14
+ mkdir cp.testdir/dir
15
+ > cp.testdir/dir/file
16
+ ln -s file cp.testdir/dir/file_symlink
17
+
18
+ > cp.testdir/file
19
+ ln -s file cp.testdir/file_symlink
20
+ ln -s dir cp.testdir/dir_symlink
21
+
22
+
23
+ # testing "test name" "command" "expected result" "file input" "stdin"
24
+
25
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
26
+ testing "cp" '\
27
+ cd cp.testdir || exit 1; cp * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
28
+ test ! -L file && test -f file || echo BAD: file
29
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
30
+ test ! -L dir && test ! -e dir || echo BAD: dir
31
+ test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
32
+ ' "\
33
+ cp: omitting directory ${sq}dir'
34
+ cp: omitting directory ${sq}dir_symlink'
35
+ 1
36
+ " "" ""
37
+
38
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
39
+ testing "cp -d" '\
40
+ cd cp.testdir || exit 1; cp -d * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
41
+ test ! -L file && test -f file || echo BAD: file
42
+ test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
43
+ test ! -L dir && test ! -e dir || echo BAD: dir
44
+ test -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
45
+ ' "\
46
+ cp: omitting directory ${sq}dir'
47
+ 1
48
+ " "" ""
49
+
50
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
51
+ testing "cp -P" '\
52
+ cd cp.testdir || exit 1; cp -P * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
53
+ test ! -L file && test -f file || echo BAD: file
54
+ test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
55
+ test ! -L dir && test ! -e dir || echo BAD: dir
56
+ test -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
57
+ ' "\
58
+ cp: omitting directory ${sq}dir'
59
+ 1
60
+ " "" ""
61
+
62
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
63
+ testing "cp -L" '\
64
+ cd cp.testdir || exit 1; cp -L * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
65
+ test ! -L file && test -f file || echo BAD: file
66
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
67
+ test ! -L dir && test ! -e dir || echo BAD: dir
68
+ test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
69
+ ' "\
70
+ cp: omitting directory ${sq}dir'
71
+ cp: omitting directory ${sq}dir_symlink'
72
+ 1
73
+ " "" ""
74
+
75
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
76
+ testing "cp -H" '\
77
+ cd cp.testdir || exit 1; cp -H * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
78
+ test ! -L file && test -f file || echo BAD: file
79
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
80
+ test ! -L dir && test ! -e dir || echo BAD: dir
81
+ test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
82
+ ' "\
83
+ cp: omitting directory ${sq}dir'
84
+ cp: omitting directory ${sq}dir_symlink'
85
+ 1
86
+ " "" ""
87
+
88
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
89
+ testing "cp -R" '\
90
+ cd cp.testdir || exit 1; cp -R * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
91
+ test ! -L file && test -f file || echo BAD: file
92
+ test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
93
+ test ! -L dir && test -d dir || echo BAD: dir
94
+ test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
95
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
96
+ test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
97
+ ' "\
98
+ 0
99
+ " "" ""
100
+
101
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
102
+ testing "cp -Rd" '\
103
+ cd cp.testdir || exit 1; cp -Rd * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
104
+ test ! -L file && test -f file || echo BAD: file
105
+ test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
106
+ test ! -L dir && test -d dir || echo BAD: dir
107
+ test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
108
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
109
+ test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
110
+ ' "\
111
+ 0
112
+ " "" ""
113
+
114
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
115
+ testing "cp -RP" '\
116
+ cd cp.testdir || exit 1; cp -RP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
117
+ test ! -L file && test -f file || echo BAD: file
118
+ test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
119
+ test ! -L dir && test -d dir || echo BAD: dir
120
+ test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
121
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
122
+ test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
123
+ ' "\
124
+ 0
125
+ " "" ""
126
+
127
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
128
+ testing "cp -RL" '\
129
+ cd cp.testdir || exit 1; cp -RL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
130
+ test ! -L file && test -f file || echo BAD: file
131
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
132
+ test ! -L dir && test -d dir || echo BAD: dir
133
+ test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
134
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
135
+ test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
136
+ ' "\
137
+ 0
138
+ " "" ""
139
+
140
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
141
+ # GNU coreutils 7.2 says:
142
+ # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
143
+ test x"$SKIP_KNOWN_BUGS" = x"" && \
144
+ testing "cp -RH" '\
145
+ cd cp.testdir || exit 1; cp -RH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
146
+ test ! -L file && test -f file || echo BAD: file
147
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
148
+ test ! -L dir && test -d dir || echo BAD: dir
149
+ test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
150
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
151
+ test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
152
+ ' "\
153
+ 0
154
+ " "" ""
155
+
156
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
157
+ # GNU coreutils 7.2 says:
158
+ # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
159
+ test x"$SKIP_KNOWN_BUGS" = x"" && \
160
+ testing "cp -RHP" '\
161
+ cd cp.testdir || exit 1; cp -RHP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
162
+ test ! -L file && test -f file || echo BAD: file
163
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
164
+ test ! -L dir && test -d dir || echo BAD: dir
165
+ test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
166
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
167
+ test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
168
+ ' "\
169
+ 0
170
+ " "" ""
171
+
172
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
173
+ testing "cp -RHL" '\
174
+ cd cp.testdir || exit 1; cp -RHL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
175
+ test ! -L file && test -f file || echo BAD: file
176
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
177
+ test ! -L dir && test -d dir || echo BAD: dir
178
+ test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
179
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
180
+ test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
181
+ ' "\
182
+ 0
183
+ " "" ""
184
+
185
+ rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
186
+ # Wow! "cp -RLH" is not the same as "cp -RHL" (prev test)!
187
+ # GNU coreutils 7.2 says:
188
+ # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
189
+ test x"$SKIP_KNOWN_BUGS" = x"" && \
190
+ testing "cp -RLH" '\
191
+ cd cp.testdir || exit 1; cp -RLH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
192
+ test ! -L file && test -f file || echo BAD: file
193
+ test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
194
+ test ! -L dir && test -d dir || echo BAD: dir
195
+ test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
196
+ test ! -L dir/file && test -f dir/file || echo BAD: dir/file
197
+ test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
198
+ ' "\
199
+ 0
200
+ " "" ""
201
+
202
+
203
+ # Clean up
204
+ rm -rf cp.testdir cp.testdir2 2>/dev/null
205
+
206
+ exit $FAILCOUNT