PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 16, 2022

[FIXED] How can I suppress ALL output from gradle?

 August 16, 2022     gradle, output, scripting, zsh     No comments   

Issue

I'm writing a script for zsh that essentially just needs to know the exit code of the following gradle command: ./gradlew installDebug. In other words, I don't want any output to the console while running this. I've tried the following: ./gradlew installDebug -q > /dev/null; 2>&1

This eliminates 99% of the output, but I still get lines like the following:

Note: Generating a MembersInjector for com.example.ui.BaseActivity. Prefer to run the dagger processor over that class instead.
Note: Generating a MembersInjector for com.example.widget.nav.NavigationDrawerActivity. Prefer to run the dagger processor over that class instead.
Note: Generating a MembersInjector for com.example.fragment.ShiftListFragment. Prefer to run the dagger processor over that class instead.

These warnings are coming from lint, which, in general, I want to keep (for when I build manually, without this script). I simply want to suppress the output in this one specific case.

I feel like I'm simply not redirecting output for a given stream correctly.


Solution

As long as you are using zsh you can use

./gradlew installDebug -q &> /dev/null

For POSIX compliant shells (including zsh) you can use

./gradlew installDebug -q > /dev/null 2>&1

The reason it did not work is the semicolon. A ; separates two commands but redirections only work per command and not per command-line. So what actually happens is equivalent to the following:

./gradlew installDebug -q > /dev/null
2>&1
  • In the first command the standard output of ./gradlew is redirected to /dev/null but standard error is not changed and thus printed normally.

  • The second is actually just a redirection without a command. In this case the behavior depends on the setting of the the parameter NULLCMD and the options SH_NULLCMD and CSH_NULLCMD. By default zsh runs cat with the given redirection applied.



Answered By - Adaephon
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing