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

[WIP] Undefined variable value yields '.' as node and may cause removing all files in tree. #3905

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bdbaddog
Copy link
Contributor

Fixes #2801. Undefined variable value yields '.' as node and may cause removing all files in tree.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt (and read the README.rst)
  • I have updated the appropriate documentation

@@ -2000,6 +2001,19 @@ def CacheDir(self, path):

def Clean(self, targets, files):
global CleanTargets

# Check for anything which evaluates to empty string, which would yield cleaning '.'
targets_strings = [(t, self.subst(t)) for t in flatten(targets) if is_String(t) and ('$' in t or t == '')]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be simpler to just let tlist and flist expand and check in them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't think using tlist or flist would allow proper checking for accidental '.' from undefined var.
Also you wouldn't be able to give as much information about what was wrong.

SCons/Environment.py Outdated Show resolved Hide resolved
SCons/Environment.py Outdated Show resolved Hide resolved
@mwichmann mwichmann added this to the 4.2 milestone Mar 27, 2021
@mwichmann mwichmann changed the title [WIP] Fixes #2801. Undefined variable value yields '.' as node and may cause removing all files in tree. [WIP] Undefined variable value yields '.' as node and may cause removing all files in tree. Mar 28, 2021
@mwichmann mwichmann modified the milestones: 4.2, NextRelease Jul 22, 2021
raise UserError(
"Targets specified to Clean() include one which evaluates to an empty string: [%s]" % ",".join(
["%s='%s'" % (str(t), s) for (t, s) in targets_strings]))
if any([s == '' for t, s in files_strings]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that one stanza checks targets_strings and the other files_strings, but this still reads quite duplicative... any way to combine?

@mwichmann
Copy link
Collaborator

Attaching a test case made from the original report (suffixed .txt instead of .py due to github limitations)

issue2801.txt

@bdbaddog bdbaddog modified the milestones: 4.4, NextRelease Jun 24, 2022
@mwichmann mwichmann removed this from the 4.5 milestone Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

Clean with empty consvar reference deletes all files in the project
2 participants