Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Remove commands to delete empty files in export #261

Merged
merged 1 commit into from
Sep 20, 2016
Merged

Remove commands to delete empty files in export #261

merged 1 commit into from
Sep 20, 2016

Conversation

benmanns
Copy link
Contributor

@benmanns benmanns commented Aug 9, 2016

This seems like a really bad idea, at least the way it's described here. In my local, fairly empty directory, find . -type f | xargs wc -l | grep '1 .' returns:

       1 ./.git/COMMIT_EDITMSG
       1 ./.git/description
       1 ./.git/HEAD
       1 ./.git/logs/HEAD
       1 ./.git/logs/refs/heads/master
      11 ./.git/objects/42/14eb21b7be0687ccb477ec1e5a8ecdf7711b05
       1 ./.git/objects/5e/001b34698fe2cd0da484fa9ab896e42df155b9
       1 ./.git/refs/heads/master
       1 ./.gitignore
       1 ./asg.tf
       1 ./dbsg.tf
       1 ./dbsn.tf
       1 ./ec2.tf
       1 ./ecc.tf
       1 ./ecsn.tf
       1 ./eip.tf
       1 ./elb.tf
       1 ./iamp.tf
       1 ./iamrp.tf
       1 ./igw.tf
       1 ./lc.tf
       1 ./nacl.tf
       1 ./nif.tf
       1 ./r53r.tf
       1 ./r53z.tf
       1 ./rds.tf
       1 ./rs.tf
       1 ./rt.tf
       1 ./rta.tf
       1 ./sn.tf
       1 ./sqs.tf
       1 ./vgw.tf
       1 ./vpc.tf

As you can see, it is deleting anything in the folder with 1 line in it. Not only that, it's deleting anything with a count of lines ending in 1. So 11, 21, 9991 line files would be deleted as well.

This checks that the files match '*.tf' and adds a space before the 1 in the grep command to fix those issues. It also removes the xargs rm.

This seems like a really bad idea, at least the way it's described here. In my local, fairly empty directory, `find . -type f | xargs wc -l | grep '1 .'` returns:

```
       1 ./.git/COMMIT_EDITMSG
       1 ./.git/description
       1 ./.git/HEAD
       1 ./.git/logs/HEAD
       1 ./.git/logs/refs/heads/master
      11 ./.git/objects/42/14eb21b7be0687ccb477ec1e5a8ecdf7711b05
       1 ./.git/objects/5e/001b34698fe2cd0da484fa9ab896e42df155b9
       1 ./.git/refs/heads/master
       1 ./.gitignore
       1 ./asg.tf
       1 ./dbsg.tf
       1 ./dbsn.tf
       1 ./ec2.tf
       1 ./ecc.tf
       1 ./ecsn.tf
       1 ./eip.tf
       1 ./elb.tf
       1 ./iamp.tf
       1 ./iamrp.tf
       1 ./igw.tf
       1 ./lc.tf
       1 ./nacl.tf
       1 ./nif.tf
       1 ./r53r.tf
       1 ./r53z.tf
       1 ./rds.tf
       1 ./rs.tf
       1 ./rt.tf
       1 ./rta.tf
       1 ./sn.tf
       1 ./sqs.tf
       1 ./vgw.tf
       1 ./vpc.tf
```

As you can see, it is deleting _anything_ in the folder with 1 line in it. Not only that, it's deleting _anything_ with a count of lines _ending_ in 1. So 11, 21, 9991 line files would be deleted as well.

This checks that the files match `'*.tf'` and adds a space before the `1` in the grep command to fix those issues. It also removes the `xargs rm`.
@coveralls
Copy link

coveralls commented Aug 9, 2016

Coverage Status

Coverage remained the same at 97.352% when pulling 400edc3 on benmanns:patch-1 into 72c96ee on dtan4:master.

@jhubert
Copy link

jhubert commented Sep 9, 2016

Yes please! This just wiped out my .git folder. Stupid me, but it would be good to not make the default so destructive. 😢

@dtan4
Copy link
Owner

dtan4 commented Sep 20, 2016

Thank you for fixing! Current example is dangerous...

LGTM 👍

@dtan4 dtan4 merged commit 1615274 into dtan4:master Sep 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants