Connect with us

Tech

Media Briefing: How the digital media industry spent the summer

Published

on

Media Briefing: How the digital media industry spent the summer

This week’s Media Briefing recaps the major events and trends from the summer as the season comes to a close.

The key hits: 

  • The M&A game is still on.
  • Digital advertising feels the impact of the economic downturn.
  • Publishers are eyeing cost-cutting opportunities in preparation of another potential recession, though hiring is not yet at a standstill.
  • Google pumps the brakes on removing third-party cookies from its Chrome browser once again.
  • Some digital media companies have begun mandating a return to office, but not all employees are thrilled.

Labor Day in the U.S. has come and gone, and with it marks the informal end of summer. As execs start evaluating 2023 budgets and assess the somewhat unexpected damages that took place in Q2 2022, it seems like a good time to recap the events from the past few months in the digital media industry for those who disconnected with some PTO.

One of the larger trends we followed the past couple of months was the macroeconomic headwinds to digital advertising, which was commonly blamed amongst publishers and platforms as the reason their ad revenue was down in Q2. Acknowledging that these potential dips in revenue might persist beyond the summer, some publishers started evaluating different money-saving measures.

Meanwhile, with COVID worries subsiding, many media companies started pushing for a return to office despite protests from their employees. And in the last few weeks of the season, we saw a bit of M&A activity, which had largely slowed down in the first half of the year, compared to 2021. On top of all this, Google once again announced it was pushing back its deadline for removing third-party cookies from Chrome, but for many large publishers, this makes little difference to their ad sales strategy. 

Below is a refresher of five trends and events from the summer to review before your next strategy meeting: 

A timeline of late summer M&A deals 

Some media conglomerates are still eyeing digital media companies as worthwhile investments even after AT&T spun off the WarnerMedia portfolio to Discovery earlier this year and Verizon Media sold HuffPost to BuzzFeed, Inc. in Nov. 2020.

Meanwhile, digital publishers are looking for technology businesses — AKA recurring revenue streams from software-as-a-service products — to scoop up to continually diversify their revenue models.

  • Aug. 8: Cox Enterprises acquired five-year-old publisher Axios for $525 million. This comes less than a year after Axios’s president and co-founder Roy Schwartz declared that “it’s too early at this point to sell the business or to merge it with something that would be larger than we are,” but given the price it sold for outpaces the company’s projected 2022 revenue by five times, it seems the deal was too good to pass up. 
  • Aug. 23: Yahoo acquired algorithm-driven news rating company The Factual for an undisclosed amount. Using artificial intelligence, the company ranks and labels articles according to their credibility level based on four criteria. Yahoo News will implement the tech into its coverage but The Factual will also continue to earn revenue from licensing the tech product to other publishers. 
  • Aug. 30: Time acquired software licensing company Brandcast for less than $101 million, according to Axios. The company, now called Time Sites, gives the company a platform to create custom websites for clients, advertisers and internal projects.

Digital advertising takes a hit

Any time there is an economic downturn, advertising budgets are going to get tighter. But after the banner year that 2021 was, the tightening of the purse strings this summer felt more shocking than usual.

Publishers’ second-quarter earnings reports confirmed the suspicion that June 2022 was not a strong month for digital advertising, and the expectation shared among many media execs is that this revenue stream will be touch and go — quite literally — through the first part of 2023

IAC’s Dotdash Meredith, The New York Times and BuzzFeed saw single-digit percentage decreases to their advertising businesses in Q2, though News Corp and The Arena Group reported increases in this area of business during the quarter.

The publishers aren’t alone in tracking decreased ad spend. Several platforms, including Twitter, Snap and Meta, reported ad revenue was down in the second quarter because of “macroeconomic headwinds.”

Cost-cutting as a precaution 

Some cost-cutting measures from spring 2020 began resurfacing over summer 2022 in publishers’ business strategies when digital advertising revenue became less reliable and slowdowns in consumer spending led to less e-commerce revenue for some media companies.

Food52 is one publisher that’s enacted a bunch of cost-cutting measures. In June it laid off 15% of its staff, or 21 people, and moved its content team and part of its creative team to a 32-hour workweek, effectively cutting those employees’ take-home pay by 20%. This follows an earlier round of layoffs this past April in which 20 employees — primarily from the content, creative and marketing teams — were let go. While the first round of layoffs was meant to “manage the margin and supply chain challenges caused by Covid,” the second round was to address all of the changes to consumer spending and brace the business against a possible recession, according to company spokespeople.

Gannett, which reported revenue losses in its second-quarter earnings report in early August, laid off approximately 65 people, slowed hiring and reduced the budgets for third-party company contracts, freelance and travel, a spokesperson said. 

Not all money-saving strategies have resulted in layoffs. Last month, Digiday reported that BuzzFeed, Inc. and IAC, owner of Dotdash Meredith, were slowing down hiring and only focusing on “critical” roles aimed at supporting top revenue lines. The New York Times, on the other hand, reported during its second-quarter earnings call that it is rolling back its marketing spending to save money. 

A few publishers used this summer to downsize their notoriously expensive New York City-based office spaces, including WarnerMedia and BuzzFeed, Inc., which subleased hundreds of thousands of square feet of office space, and Dotdash Meredith put over 300,000 square feet of office space on the market earlier in the year. 

The uphill battle of returning to the office 

For the publishers that are still holding onto office space, getting employees to use it has proven to be a slight challenge. 

The Washington Post was in hot water with The Washington Post Guild in June after the company’s leadership mandated staffers come into its office at least three times per week or face disciplinary action, according to a report by The Daily Beast. The fights between unions and media execs over in-office mandates have been going on long before the summer began, but were reignited by the BA.5 variant.

Other newly combined publishers, like BuzzFeed/Complex, Dotdash/Meredith and Vox Media/Group Nine, faced a puzzle of a challenge to try and bring together once completely independent staff for the first time after merging while remote. 

Google delayed the cookie apocalypse … again  

Google’s new deadline for removing third-party cookies from its Chrome browser is the end of 2024 giving publishers, advertisers and ad tech companies another two years to figure out a solution for measuring ad performance in a privacy-compliant way. 

For some larger publishers who have honed their first-party data strategies, this gift of time is unneeded as third-party cookies play a marginal part of their ad businesses. 

“When Google announced this push back to 2024, it was a minor blip on the radar,” said Vox Media CRO Ryan Pauley on an episode of the Digiday Podcast. “And I remember I saw the headline, but we didn’t scramble to understand what it would mean for our business the way that we did when the first delay came out — a push back to 2023.” Pauley added that in 2021, the lion’s share — three-quarters — of the company’s total impressions ran through the company’s first-party data solution Forte

But for others, these continued delays are worrisome because it reduces the sense of urgency that previously was the light underneath the industry’s procrastinators — publishers, marketers and vendors alike. 

What we’ve heard

“We know that dot-com is really where a lot of [commerce] action happens, but [we’re] thinking about how do we use the platforms as another marketing tool that’s helping drive [conversions]? And that’s testing TikTok versus Instagram versus leveraging creators and influencers. It’s [about] how we leverage peripheral triggers to help [complete] the [buying] process.”

A media company CRO on how they’re using social commerce in their fourth-quarter commerce strategy

3 questions with The BBC’s Jonathan Aspinwall on rebooting its American politics podcast

The BBC’s sights are set across the pond this year: In February, the U.K.-based broadcast company announced plans to double its North American digital news team and expand its audience growth team to grow revenue opportunities outside of the U.K. Now, a key part of attracting more North American listeners is the revival of its American political podcast “Americast.”

Originally created in 2020, “Americast” released its first episode in six months on Aug. 31, featuring three new hosts and a different focus. The podcast went on hiatus after former hosts Emily Maitlis and Jon Sopel announced their exits from the BBC in February. North America correspondent Anthony “The Zurch” Zurcher is returning to the weekly podcast, while new hosts include North America editor Sarah Smith, former North America editor and “Today” presenter Justin Webb and disinformation and social media correspondent Marianna Spring. 

As a public service broadcaster, the BBC is funded by a license fee in the U.K., which is paid annually by all households with a TV set and is under threat to be eliminated by the U.K. government. Outside of the U.K., the BBC operates a commercial business selling content, advertising and sponsorship deals. Growing the BBC’s listenership in North America and beyond is a play to also drive revenue – the broadcaster’s podcasts are monetized with ads through a deal with Acast.

Digiday spoke to Jonathan Aspinwall, the BBC’s senior editor of news podcasts, to hear why “Americast” — which has a majority of U.K. listeners — will focus on disinformation leading up to the U.S. midterm elections this November.  – Sara Guaglione

This conversation has been edited and condensed.

Why is the BBC bringing back Americast?

The next year brings a huge range of engaging topics — the congressional midterms, the primaries and the campaigns leading up to them. All of that provides ready-made drama with the winners and losers, amongst so many of these interesting personalities. “Americasters” — as we call our listeners — were asking us to come back, but we wanted to make sure we had the right team in place. We see our hosts as these trusted friends who have a global perspective on what’s going on in America. That’s the central tenet of the podcast.

What’s different this time around, other than the new hosts?

The [disinformation focus] is what’s new, by having Marianna and her expertise on the podcast. Also, we have a broad range of hosts – two of them are in the States. We’re also doing an experiment with Pew Research Center, where we created undercover [fictional] voters who represent the political spectrum. We created five profiles – each one has a different name, interests, where they live. They have computer-generated photos. Each one has accounts on TikTok, Facebook, Instagram, Twitter [and YouTube]. Then we analyze in real time what information is pushed their way to see what content is recommended to U.S. voters on social media. It’s really pertinent ahead of the midterms, to see what people are exposed to.

Why focus the podcast on disinformation?

Americasters ask us a lot of questions. They really shape the pod. We’re finding that, increasingly, the questions they’re asking and the comments they’re making are about disinformation and what’s going on in social media and how that’s shaping American public opinion – the trends, the concerns. It’s our job to lift the lid and explore this. 

We would also love to crack the U.S. market. I mean, we already are – but that’s really important to us. It’s a global podcast. But we worked out that internationally and in North America, people are hungry for information on impartiality, trust and disinformation. So we lined up our hosts to reflect that.

Numbers to know

6: The number of top editors that National Geographic laid off last week while reorganizing its editorial structure. 

-18.4%: The average reduction of the top 100 publishers’ promotional prices for subscriptions over a two-month period from June to August 2022. 

35%: The percentage of 55 publisher respondents in a new Digiday+ Research study who said their company hasn’t made any preparations for a potential recession.

What we’ve covered

Digiday+ Research: Most publishers agree a recession is coming, but a third haven’t done anything to prepare:

  • The vast majority of publishers agree we’ll be in a recession within the next year.
  • Despite that, more than a third of respondents to Digiday’s survey of 55 publishers said their company hasn’t done anything to prepare for a recession.

Read more about publishers’ recession outlooks here.

The definitive guide to what’s in and out in ad tech in 2022:

  • Ad tech has seen a lot of changes so far this year, so we made a definitive list of what’s in and what’s out to help make sense of it all.
  • For example, hype for data clean rooms is definitely out while confusion over data clean rooms is absolutely in. 

Read more about the ins and outs of ad tech here

How CBS News’ co-presidents Neeraj Khemlani and Wendy McMahon are stepping up their streaming news outlet:

  • CBS News is adding more traditional TV talent to its streaming outlet. 
  • In the latest Digiday Podcast, CBS News and Stations co-presidents and co-heads Neeraj Khemlani and Wendy McMahon discussed the new nightly primetime news program and the streamer’s development since its November 2014 debut.

Hear Khemlani and McMahon on the latest Digiday Podcast episode here

How one startup hopes to decentralize ad exchanges to benefit publishers and agencies:

  • Two-year-old London startup Alkimi Exchange is proposing a decentralized version of the current ad exchange system.
  • The company is beta testing with U.K.-based publishers and will launch in the U.S. and U.K. in October. 

Read more about Alkimi Exchange here

Media companies downsize office spaces in NYC:

  • Media companies that continue to offer the flexibility of remote work are reconsidering office spaces that are going unused in expensive locations like New York City.
  • WarnerMedia put over 450,000 square feet of office space in Midtown Manhattan on the market for sublease last quarter, meanwhile, Dotdash Meredith put over 300,000 square-feet of office space in the Financial District on the market in the first quarter.

Read more about publishers’ NYC-based office spaces here.

What we’re reading

Vice Media explores a content deal with MBC:

While the digital media company shops for a buyer, The New York Times reported that Vice is also exploring a deal with MBC, a media giant partly owned by the Saudi government, to create a new content partnership in the region.

Another top CNN personality is out:

John Harwood, who served as a White House correspondent for two-and-a-half years at the company, abruptly departed CNN last week, raising more questions about CNN’s editorial strategy, according to Poynter.

Axel Springer’s CEO has a different view of American media:

Less than a year after Mathias Döpfner’s company bought Politico, the CEO is concerned that American media has become too polarized, according to The Washington Post.

Federal privacy bill may have hit a dead end:

House Speaker Nancy Pelosi did not support the existing draft of the American Data Privacy and Protection Act, which means it could be indefinitely stalled in the House of Representatives, according to Adweek.

Read More

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published.

Tech

Google Pixel 7 and 7 Pro are getting a built-in VPN at no extra cost

Published

on

By

Google Pixel 7 and 7 Pro are getting a built-in VPN at no extra cost
Google Pixel 7 Pro hands on front Snow



(Image credit: Future / Lance Ulanoff)

Users of the Google Pixel 7 and 7 Pro devices will be able to secure their data without the need to pay for an additional Android VPN after the company said it would be including its Google One VPN service at no extra cost. 

The move will make the Pixel 7 and 7 Pro the first smartphones to include a free VPN connection. 

The offer is restricted to just some countries, though – and what’s more, some data won’t be secured inside the VPN tunnel.  

Peace of mind when you connect online ✨Later this year, #Pixel7 and 7 Pro will be the only phones with a VPN by Google One—at no extra cost.¹#MadeByGoogle¹See image for more info pic.twitter.com/P7lzyoMdekOctober 6, 2022

See more

Google Pixel 7 VPN

Despite the aforementioned limits, the big tech giant assures that the VPN software won’t associate users’ app and browsing data with users’ accounts. 

Google One VPN typically costs around $10 per month as part of the company’s Premium One plan, which also comes with a 2TB of cloud storage on top. 

This decision is the latest move to bring Google’s mobile data security to the next level. Not too long ago, the company made Google One VPN available also for iOS devices, and also introduced the option of having an always-on VPN across its latest smartphones. 

Google promises that its secure VPN software will shield your phone against hackers on unsecure networks, like public Wi-Fi. It will also hide your IP address so that third parties won’t be able to track your location.

Shorter for virtual private network, a VPN is exactly the tool you want to shield your sensitive data as it masks your real location and encrypts all your data in transit. Beside privacy, it can allow you to bypass geo-restrictions and other online blocks. 

Chiara is a multimedia journalist, with a special eye for latest trends and issues in cybersecurity. She is a Staff Writer at Future with a focus on VPNs. She mainly writes news and features about data privacy, online censorship and digital rights for TechRadar, Tom’s Guide and T3. With a passion for digital storytelling in all its forms, she also loves photography, video making and podcasting. Originally from Milan in Italy, she is now based in Bristol, UK, since 2018.

Read More

Continue Reading

Tech

The Steam Deck dock is finally here and will ship faster than you think

Published

on

By

The Steam Deck dock is finally here and will ship faster than you think
a steam deck placed in a steam deck dock



(Image credit: Valve)

After months of waiting and delays, Valve has finally announced that the Steam Deck dock is available for purchase on its official site.

Not only that but, according to Valve, the dock will ship out in an incredibly fast one to two weeks, which pairs with the fact that the Steam Deck itself is now shipping with no wait time (not to mention that it’s incredibly easy to set up). The port selection is pretty solid as well, with the dock featuring three USB-A 3.1 gen 1 ports, one Ethernet port, a DisplayPort 1.4, and an HDMI 2.0 port. And for its power supply, it uses a USB-C passthrough delivery.

A Steam Deck dock will run you $90 (around £81 / AU$140), which is a bit steeper than most third-party options on the market right now. But for those waiting it out for an official product until now, price most likely will not be an issue.

Is it worth buying? 

Considering that even Steam Decks themselves are shipping without a queue and that the dock has such a quick turnaround to delivery, it seems that the supply chain issues that had been gripping Valve are loosening considerably.

However, the deck itself is far from perfect. Because of the fact that it uses USB-C for the display port, a third-party USB-C dock that uses its own power supply and video out will output the display of the official dock. 

And as mentioned before, the price of the official Steam Deck dock is steeper than many third-party options on the market, meaning that those who are on a budget might pass this product up in favor of a lower-priced one.

There are also some bugs that Valve is working on fixing at this time, including one involving compatibility with LG displays. According to the FAQ, if the “Docking Station is connected via HDMI, sleep/wake can result in visual noise.”

It might be worth waiting for Valve to work out the kinks of its dock before investing in one. And while you’re waiting, research other options that might better suit your needs.

Allisa has been freelancing at TechRadar for nine months before joining as a Computing Staff Writer. She mainly covers breaking news and rumors in the computing industry, and does reviews and featured articles for the site. In her spare time you can find her chatting it up on her two podcasts, Megaten Marathon and Combo Chain, as well as playing any JRPGs she can get her hands on.

Read More

Continue Reading

Tech

Why doesn’t Bash’s `set -e` do what I expected?

Published

on

By

Why doesn’t set -e (or set -o errexit, or trap ERR) do what I expected?

set -e was an attempt to add “automatic error detection” to the shell. Its goal was to cause the shell to abort any time an error occurred, so you don’t have to put || exit 1 after each important command. This does not work well in practice.

The goal of automatic error detection is a noble one, but it requires the ability to tell when an error actually occurred. In modern high-level languages, most tasks are performed by using the language’s builtin commands or features. The language knows whether (for example) you tried to divide by zero, or open a file that you can’t open, and so on. It can take action based on this knowledge.

But in the shell, most of the tasks you actually care about are done by external programs. The shell can’t tell whether an external program encountered something that it considers an error — and even if it could, it wouldn’t know whether the error is an important one, worthy of aborting the entire program, or whether it should carry on.

The only information conveyed to the shell by the external program is an exit status — by convention, 0 for success, and non-zero for “some kind of error”. The developers of the original Bourne shell decided that they would create a feature that would allow the shell to check the exit status of every command that it runs, and abort if one of them returns non-zero. Thus, set -e was born.

But many commands return non-zero even when there wasn’t an error. For example,

if [ -d /foo ]; then ...; else ...; fi

If the directory doesn’t exist, the [ command returns non-zero. Clearly we don’t want to abort when that happens — our script wants to handle that in the else part. So the shell implementors made a bunch of special rules, like “commands that are part of an if test are immune”, and “commands in a pipeline, other than the last one, are immune”.

These rules are extremely convoluted, and they still fail to catch even some remarkably simple cases. Even worse, the rules change from one Bash version to another, as Bash attempts to track the extremely slippery POSIX definition of this “feature”. When a SubShell is involved, it gets worse still — the behavior changes depending on whether Bash is invoked in POSIX mode. Another wiki has a page that covers this in more detail. Be sure to check the caveats.

A reference comparing behavior across various historical shells also exists.

Story time

Consider this allegory, originally posted to bug-bash:

Once upon a time, a man with a dirty lab coat and long, uncombed hair
showed up at the town police station, demanding to see the chief of
police.  "I've done it!" he exclaimed.  "I've built the perfect
criminal-catching robot!"

The police chief was skeptical, but decided that it might be worth
the time to see what the man had invented.  Also, he secretly thought,
it might be a somewhat unwise move to completely alienate the mad
scientist and his army of hunter robots.

So, the man explained to the police chief how his invention could tell
the difference between a criminal and law-abiding citizen using a
series of heuristics.  "It's especially good at spotting recently
escaped prisoners!" he said.  "Guaranteed non-lethal restraints!"

Frowning and increasingly skeptical, the police chief nevertheless
allowed the man to demonstrate one robot for a week.  They decided that
the robot should patrol around the jail.  Sure enough, there was a
jailbreak a few days later, and an inmate digging up through the
ground outside of the prison facility was grabbed by the robot and
carried back inside the prison.

The surprised police chief allowed the robot to patrol a wider area.
The next day, the chief received an angry call from the zookeeper.
It seems the robot had cut through the bars of one of the animal cages,
grabbed the animal, and delivered it to the prison.

The chief confronted the robot's inventor, who asked what animal it
was.  "A zebra," replied the police chief.  The man slapped his head and
exclaimed, "Curses!  It was fooled by the black and white stripes!
I shall have to recalibrate!"  And so the man set about rewriting the
robot's code.  Black and white stripes would indicate an escaped
inmate UNLESS the inmate had more than two legs.  Then it should be
left alone.

The robot was redeployed with the updated code, and seemed to be
operating well enough for a few days.  Then on Saturday, a mob of
children in soccer clothing, followed by their parents, descended
on the police station.  After the chaos subsided, the chief was told
that the robot had absconded with the referee right in the middle of
a soccer game.

Scowling, the chief reported this to the scientist, who performed a
second calibration.  Black and white stripes would indicate an escaped
inmate UNLESS the inmate had more than two legs OR had a whistle on
a necklace.

Despite the second calibration, the police chief declared that the robot
would no longer be allowed to operate in his town.  However, the news
of the robot had spread, and requests from many larger cities were
pouring in.  The inventor made dozens more robots, and shipped them off
to eager police stations around the nation.  Every time a robot grabbed
something that wasn't an escaped inmate, the scientist was consulted,
and the robot was recalibrated.

Unfortunately, the inventor was just one man, and he didn't have the
time or the resources to recalibrate EVERY robot whenever one of them
went awry.  The robot in Shangri-La was recalibrated not to grab a
grave-digger working on a cold winter night while wearing a ski mask,
and the robot in Xanadu was recalibrated not to capture a black and
white television set that showed a movie about a prison break, and so
on.  But the robot in Xanadu would still grab grave-diggers with ski
masks (which it turns out was not common due to Xanadu's warmer climate),
and the robot in Shangri-La was still a menace to old televisions (of
which there were very few, the people of Shangri-La being on the average
more wealthy than those of Xanadu).

So, after a few years, there were different revisions of the
criminal-catching robot in most of the major cities.  In some places,
a clever criminal could avoid capture by wearing a whistle on a string
around the neck.  In others, one would be well-advised not to wear orange
clothing in certain rural areas, no matter how close to the Harvest
Festival it was, unless one also wore the traditional black triangular
eye-paint of the Pumpkin King.

Many people thought, "This is lunacy!"  But others thought the robots
did more good than harm, all things considered, and so in some places
the robots are used, while in other places they are shunned.

The end.

Exercises

Or, “so you think set -e is OK, huh?”

Exercise 1: why doesn’t this example print anything?

   1 
   2 set -e
   3 i=0
   4 let i++
   5 echo "i is $i"

Exercise 2: why does this one sometimes appear to work? In which versions of bash does it work, and in which versions does it fail?

   1 
   2 set -e
   3 i=0
   4 ((i++))
   5 echo "i is $i"

Exercise 3: why aren’t these two scripts identical?

   1 
   2 set -e
   3 test -d nosuchdir && echo no dir
   4 echo survived
   1 
   2 set -e
   3 f() { test -d nosuchdir && echo no dir; }
   4 f
   5 echo survived

Exercise 4: why aren’t these two scripts identical?

   1 set -e
   2 f() { test -d nosuchdir && echo no dir; }
   3 f
   4 echo survived
   1 set -e
   2 f() { if test -d nosuchdir; then echo no dir; fi; }
   3 f
   4 echo survived

Exercise 5: under what conditions will this fail?

   1 set -e
   2 read -r foo < configfile

(Answers)

But wait, there’s more!

Even if you use expr(1) (which we do not recommend — use arithmetic expressions instead), you still run into the same problem:

   1 set -e
   2 foo=$(expr 1 - 1)
   3 
   4 echo survived

Subshells from command substitution unset set -e, however (unless inherit_errexit is set with Bash 4.4):

   1 set -e
   2 foo=$(expr 1 - 1; true)
   3 
   4 echo survived

Note that set -e is not unset for commands that are run asynchronously, for example with process substitution:

   1 set -e
   2 mapfile foo < <(true; echo foo)
   3 echo ${foo[-1]} 
   4 mapfile foo < <(false; echo foo)
   5 echo ${foo[-1]} 

Another pitfall associated with set -e occurs when you use commands that look like assignments but aren’t, such as export, declare, typeset or local.

   1 set -e
   2 f() { local var=$(somecommand that fails); }
   3 f    
   4 
   5 g() { local var; var=$(somecommand that fails); }
   6 g    

In function f, the exit status of somecommand is discarded. It won’t trigger the set -e because the exit status of local masks it (the assignment to the variable succeeds, so local returns status 0). In function g, the set -e is triggered because it uses a real assignment which returns the exit status of somecommand.

A particularly dangerous pitfall with set -e is combining functions with conditionals. The following snippets will not behave the same way:

   1 set -e
   2 f() { false; echo "This won't run, right?"; }
   3 f
   4 echo survived
   1 set -e
   2 f() { false; echo "This won't run, right?"; }
   3 if f; then  
   4     echo survived
   5 fi

As soon as a function is used as a conditional (in a list or with a conditional test or loop) set -e stops being applied within the function. This may not only cause code to unexpectedly start executing in the function but also change its return status!

Using Process substitution, the exit code is also discarded as it is not visible from the main script:

   1 set -e
   2 cat <(somecommand that fails)
   3 echo survived

Using a pipe makes no difference, as only the rightmost process is considered:

   1 set -e
   2 somecommand that fails | cat -
   3 echo survived

set -o pipefail is a workaround by returning the exit code of the first failed process:

   1 set -e -o pipefail
   2 failcmd1 | failcmd2 | cat -
   3 
   4 echo survived

though with pipefail in effect, code like this will sometimes cause an error, depending on whether the output of somecmd exceeds the size of the pipe buffer or not:

   1 set -e -o pipefail
   2 somecmd | head -n1
   3 
   4 echo survived

So-called strict mode

In the mid 2010s, some people decided that the combination of set -e, set -u and set -o pipefail should be used by default in all new shell scripts. They call this unofficial bash strict mode, and they claim that it “makes many classes of subtle bugs impossible” and that if you follow this policy, you will “spend much less time debugging, and also avoid having unexpected complications in production”.

As we’ve already seen in the exercises above, these claims are dubious at best. The behavior of set -e is quite unpredictable. If you choose to use it, you will have to be hyper-aware of all the false positives that can cause it to trigger, and work around them by “marking” every line that’s allowed to fail with something like ||true.

Conclusions

GreyCat‘s personal recommendation is simple: don’t use set -e. Add your own error checking instead.

rking’s personal recommendation is to go ahead and use set -e, but beware of possible gotchas. It has useful semantics, so to exclude it from the toolbox is to give into FUD.

geirha’s personal recommendation is to handle errors properly and not rely on the unreliable set -e.

Read More

Continue Reading

Trending

Copyright © 2022 Xanatan